Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/tektoncd/hub/api v0.0.0-20201027094520-f56d79d14d70
github.com/tektoncd/pipeline v0.17.1-0.20201007165454-9611f3e4509e
github.com/tektoncd/plumbing v0.0.0-20200430135134-e53521e1d887
github.com/tektoncd/triggers v0.8.2-0.20201007153255-cb1879311818
github.com/tektoncd/triggers v0.9.1
github.com/tidwall/gjson v1.6.0 // indirect
go.opencensus.io v0.22.4
go.uber.org/multierr v1.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,8 @@ github.com/tektoncd/plumbing v0.0.0-20200217163359-cd0db6e567d2/go.mod h1:QZHgU0
github.com/tektoncd/plumbing v0.0.0-20200430135134-e53521e1d887 h1:crv70CBAJ2gZFSbf13aRVwdbjR2GYwTms/ZEok/SnFM=
github.com/tektoncd/plumbing v0.0.0-20200430135134-e53521e1d887/go.mod h1:cZPJIeTIoP7UPTxQyTQLs7VE1TiXJSNj0te+If4Q+jI=
github.com/tektoncd/plumbing/pipelinerun-logs v0.0.0-20191206114338-712d544c2c21/go.mod h1:S62EUWtqmejjJgUMOGB1CCCHRp6C706laH06BoALkzU=
github.com/tektoncd/triggers v0.8.2-0.20201007153255-cb1879311818 h1:KWEoOYU9ht2G5iW/BbGEqGRZwrWVUuTdEeDsuEXR4go=
github.com/tektoncd/triggers v0.8.2-0.20201007153255-cb1879311818/go.mod h1:BccgHGtBbJp6gpKCxU/X2j6it4lLFE6HIT7zn7BKX94=
github.com/tektoncd/triggers v0.9.1 h1:KR4/mIfcCv2MdhQWvH/4ZkEzJvsQm72mL8ZtcKA71Kc=
github.com/tektoncd/triggers v0.9.1/go.mod h1:BccgHGtBbJp6gpKCxU/X2j6it4lLFE6HIT7zn7BKX94=
github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
github.com/tetafro/godot v0.4.2/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
github.com/tidwall/gjson v1.3.5/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
Expand Down
30 changes: 30 additions & 0 deletions pkg/cmd/eventlistener/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ const describeTemplate = `{{decorate "bold" "Name"}}: {{ .EventListener.Name }}
{{- end }}
{{ " " }}
{{- end }}
{{- if isBindingNameExist $v.Bindings }}
NAME VALUE
{{- range $b := $v.Bindings }}
{{- if ne $b.Name "" }}
{{ decorate "bullet" $b.Name }} {{ $b.Value }}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure what to make of this, but the example [here](kubectl apply -f https://raw.githubusercontent.com/tektoncd/triggers/master/examples/eventlisteners/eventlistener-embedded-bindings.yaml) comes back with a <nil> for value:

Name:                      listener-embed-binding
Namespace:                 default
Service Account:           tekton-triggers-example-sa
URL:                       http://el-listener-embed-binding.default.svc.cluster.local:8080
EventListnerServiceName:   el-listener-embed-binding
 
EventListenerTriggers

 NAME
 ∙ foo-trig
 
 BINDINGS

  REF                  KIND   APIVERSION
  ∙ pipeline-binding          
 
  NAME                VALUE
  ∙ message-binding   <nil>
 
  SPEC
  ∙ Params
    message   Hello from the Triggers EventListener(listener-embed-binding)!
 
 TEMPLATE REF          APIVERSION
 ∙ pipeline-template 

I suppose we can leave it for now, but might be nice to clean up in future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely, we will need cleanup, as the deprecated part becomes unsupported.

{{- end }}
{{- end }}
{{ " " }}
{{- end }}

{{- if isBindingSpecExist $v.Bindings }}
SPEC
Expand All @@ -95,8 +104,13 @@ const describeTemplate = `{{decorate "bold" "Name"}}: {{ .EventListener.Name }}
{{ " " }}
{{- end }}
{{- end }}
{{- if isTemplateRefExist $v.Template }}
TEMPLATE REF APIVERSION
{{ decorate "bullet" $v.Template.Ref }} {{ $v.Template.APIVersion }}
{{- else }}
TEMPLATE NAME APIVERSION
{{ decorate "bullet" $v.Template.Name }} {{ $v.Template.APIVersion }}
{{- end }}
{{- if eq $v.ServiceAccountName "" }}
{{- else }}
{{ " " }}
Expand Down Expand Up @@ -225,6 +239,8 @@ func printEventListenerDescription(s *cli.Stream, p cli.Params, elName string) e
"getEventListenerName": getEventListenerName,
"isBindingRefExist": isBindingRefExist,
"isBindingSpecExist": isBindingSpecExist,
"isBindingNameExist": isBindingNameExist,
"isTemplateRefExist": isTemplateRefExist,
}

w := tabwriter.NewWriter(s.Out, 0, 5, 3, ' ', tabwriter.TabIndent)
Expand Down Expand Up @@ -277,3 +293,17 @@ func isBindingSpecExist(bindings []*v1alpha1.EventListenerBinding) bool {
}
return specExist
}

func isBindingNameExist(bindings []*v1alpha1.EventListenerBinding) bool {
nameExist := false
for _, j := range bindings {
if j.Name != "" {
return true
}
}
return nameExist
}

func isTemplateRefExist(templates *v1alpha1.EventListenerTemplate) bool {
return templates.Ref != nil
}
67 changes: 67 additions & 0 deletions pkg/cmd/eventlistener/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,73 @@ func TestEventListenerDescribe_OneTriggerWithMultipleTriggerBinding(t *testing.T
executeEventListenerCommand(t, els)
}

func TestEventListenerDescribe_OneTriggerWithTriggerBindingName(t *testing.T) {
bindingval := "somevalue"

els := []*v1alpha1.EventListener{
{
ObjectMeta: metav1.ObjectMeta{
Name: "el1",
Namespace: "ns",
},
Spec: v1alpha1.EventListenerSpec{
Triggers: []v1alpha1.EventListenerTrigger{
{
Bindings: []*v1alpha1.EventListenerBinding{
{
Name: "binding",
Value: &bindingval,
},
},
Template: &v1alpha1.EventListenerTemplate{
Name: "tt1",
Ref: nil,
APIVersion: "v1alpha1",
Spec: nil,
},
Name: "tt1",
},
},
},
},
}

executeEventListenerCommand(t, els)
}

func TestEventListenerDescribe_TriggerWithTriggerTemplateRef(t *testing.T) {
bindingval := "somevalue"
tempRef := "someref"

els := []*v1alpha1.EventListener{
{
ObjectMeta: metav1.ObjectMeta{
Name: "el1",
Namespace: "ns",
},
Spec: v1alpha1.EventListenerSpec{
Triggers: []v1alpha1.EventListenerTrigger{
{
Bindings: []*v1alpha1.EventListenerBinding{
{
Name: "binding",
Value: &bindingval,
},
},
Template: &v1alpha1.EventListenerTemplate{
Ref: &tempRef,
APIVersion: "v1alpha1",
},
Name: "tt1",
},
},
},
},
}

executeEventListenerCommand(t, els)
}

func TestEventListenerDescribe_OneTriggerWithEmptyTriggerBinding(t *testing.T) {
els := []*v1alpha1.EventListener{
el.EventListener("el1", "ns",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Name: el1
Namespace: ns

EventListenerTriggers

NAME
tt1

BINDINGS

NAME VALUE
binding somevalue

TEMPLATE NAME APIVERSION
tt1 v1alpha1

Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
{
"bindings": [
{
"kind": "TriggerBinding",
"ref": "tb1"
"ref": "tb1",
"kind": "TriggerBinding"
},
{
"kind": "ClusterTriggerBinding",
"ref": "tb2",
"kind": "ClusterTriggerBinding",
"apiversion": "v1alpha1"
},
{
"kind": "TriggerBinding",
"ref": "tb3",
"kind": "TriggerBinding",
"apiversion": "v1alpha1"
}
],
Expand All @@ -48,12 +48,12 @@
{
"bindings": [
{
"kind": "TriggerBinding",
"ref": "tb4"
"ref": "tb4",
"kind": "TriggerBinding"
},
{
"kind": "ClusterTriggerBinding",
"ref": "tb5",
"kind": "ClusterTriggerBinding",
"apiversion": "v1alpha1"
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Name: el1
Namespace: ns

EventListenerTriggers

NAME
tt1

BINDINGS

NAME VALUE
binding somevalue

TEMPLATE REF APIVERSION
someref v1alpha1

27 changes: 0 additions & 27 deletions third_party/VENDOR-LICENSE/LICENSE

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014,2015 Daniel Imfeld

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.
22 changes: 22 additions & 0 deletions third_party/VENDOR-LICENSE/github.com/gorilla/websocket/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2013 The Gorilla WebSocket 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.

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 HOLDER 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.
21 changes: 21 additions & 0 deletions third_party/VENDOR-LICENSE/github.com/mitchellh/go-homedir/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2013 Mitchell Hashimoto

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.
Loading