Skip to content

Commit

Permalink
Add triggertemplate list
Browse files Browse the repository at this point in the history
This will add the trigger client to the cli and
add the subcommand triggertemplate to the tkn cli

This will add the list or ls command to triggertemplate
group

Add tests and docs

Part of #530
  • Loading branch information
piyush-garg authored and tekton-robot committed Dec 23, 2019
1 parent 369ab71 commit 89e99a4
Show file tree
Hide file tree
Showing 103 changed files with 8,510 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/cmd/tkn.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ CLI for tekton pipelines
* [tkn resource](tkn_resource.md) - Manage pipeline resources
* [tkn task](tkn_task.md) - Manage tasks
* [tkn taskrun](tkn_taskrun.md) - Manage taskruns
* [tkn triggertemplate](tkn_triggertemplate.md) - Manage triggertemplates
* [tkn version](tkn_version.md) - Prints version information

25 changes: 25 additions & 0 deletions docs/cmd/tkn_triggertemplate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## tkn triggertemplate

Manage triggertemplates

***Aliases**: tt,triggertemplates*

### Synopsis

Manage triggertemplates

### Options

```
-c, --context string name of the kubeconfig context to use (default: kubectl config current-context)
-h, --help help for triggertemplate
-k, --kubeconfig string kubectl config file (default: $HOME/.kube/config)
-n, --namespace string namespace to use (default: from $KUBECONFIG)
-C, --nocolour disable colouring (default: false)
```

### SEE ALSO

* [tkn](tkn.md) - CLI for tekton pipelines
* [tkn triggertemplate list](tkn_triggertemplate_list.md) - Lists triggertemplates in a namespace

49 changes: 49 additions & 0 deletions docs/cmd/tkn_triggertemplate_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## tkn triggertemplate list

Lists triggertemplates in a namespace

***Aliases**: ls*

### Usage

```
tkn triggertemplate list
```

### Synopsis

Lists triggertemplates in a namespace

### Examples

List all triggertemplates in namespace 'bar':

tkn triggertemplate list -n bar

or

tkn tt ls -n bar


### Options

```
--allow-missing-template-keys If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. (default true)
-h, --help help for list
-o, --output string Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.
--template string Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
```

### Options inherited from parent commands

```
-c, --context string name of the kubeconfig context to use (default: kubectl config current-context)
-k, --kubeconfig string kubectl config file (default: $HOME/.kube/config)
-n, --namespace string namespace to use (default: from $KUBECONFIG)
-C, --nocolour disable colouring (default: false)
```

### SEE ALSO

* [tkn triggertemplate](tkn_triggertemplate.md) - Manage triggertemplates

86 changes: 86 additions & 0 deletions docs/man/man1/tkn-triggertemplate-list.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
.TH "TKN\-TRIGGERTEMPLATE\-LIST" "1" "" "Auto generated by spf13/cobra" ""
.nh
.ad l


.SH NAME
.PP
tkn\-triggertemplate\-list \- Lists triggertemplates in a namespace


.SH SYNOPSIS
.PP
\fBtkn triggertemplate list\fP


.SH DESCRIPTION
.PP
Lists triggertemplates in a namespace


.SH OPTIONS
.PP
\fB\-\-allow\-missing\-template\-keys\fP[=true]
If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.

.PP
\fB\-h\fP, \fB\-\-help\fP[=false]
help for list

.PP
\fB\-o\fP, \fB\-\-output\fP=""
Output format. One of: json|yaml|name|go\-template|go\-template\-file|template|templatefile|jsonpath|jsonpath\-file.

.PP
\fB\-\-template\fP=""
Template string or path to template file to use when \-o=go\-template, \-o=go\-template\-file. The template format is golang templates [
\[la]http://golang.org/pkg/text/template/#pkg-overview\[ra]].


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
\fB\-c\fP, \fB\-\-context\fP=""
name of the kubeconfig context to use (default: kubectl config current\-context)

.PP
\fB\-k\fP, \fB\-\-kubeconfig\fP=""
kubectl config file (default: $HOME/.kube/config)

.PP
\fB\-n\fP, \fB\-\-namespace\fP=""
namespace to use (default: from $KUBECONFIG)

.PP
\fB\-C\fP, \fB\-\-nocolour\fP[=false]
disable colouring (default: false)


.SH EXAMPLE
.PP
List all triggertemplates in namespace 'bar':

.PP
.RS

.nf
tkn triggertemplate list \-n bar

.fi
.RE

.PP
or

.PP
.RS

.nf
tkn tt ls \-n bar

.fi
.RE


.SH SEE ALSO
.PP
\fBtkn\-triggertemplate(1)\fP
45 changes: 45 additions & 0 deletions docs/man/man1/tkn-triggertemplate.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.TH "TKN\-TRIGGERTEMPLATE" "1" "" "Auto generated by spf13/cobra" ""
.nh
.ad l


.SH NAME
.PP
tkn\-triggertemplate \- Manage triggertemplates


.SH SYNOPSIS
.PP
\fBtkn triggertemplate\fP


.SH DESCRIPTION
.PP
Manage triggertemplates


.SH OPTIONS
.PP
\fB\-c\fP, \fB\-\-context\fP=""
name of the kubeconfig context to use (default: kubectl config current\-context)

.PP
\fB\-h\fP, \fB\-\-help\fP[=false]
help for triggertemplate

.PP
\fB\-k\fP, \fB\-\-kubeconfig\fP=""
kubectl config file (default: $HOME/.kube/config)

.PP
\fB\-n\fP, \fB\-\-namespace\fP=""
namespace to use (default: from $KUBECONFIG)

.PP
\fB\-C\fP, \fB\-\-nocolour\fP[=false]
disable colouring (default: false)


.SH SEE ALSO
.PP
\fBtkn(1)\fP, \fBtkn\-triggertemplate\-list(1)\fP
2 changes: 1 addition & 1 deletion docs/man/man1/tkn.1
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ CLI for tekton pipelines

.SH SEE ALSO
.PP
\fBtkn\-clustertask(1)\fP, \fBtkn\-completion(1)\fP, \fBtkn\-condition(1)\fP, \fBtkn\-pipeline(1)\fP, \fBtkn\-pipelinerun(1)\fP, \fBtkn\-resource(1)\fP, \fBtkn\-task(1)\fP, \fBtkn\-taskrun(1)\fP, \fBtkn\-version(1)\fP
\fBtkn\-clustertask(1)\fP, \fBtkn\-completion(1)\fP, \fBtkn\-condition(1)\fP, \fBtkn\-pipeline(1)\fP, \fBtkn\-pipelinerun(1)\fP, \fBtkn\-resource(1)\fP, \fBtkn\-task(1)\fP, \fBtkn\-taskrun(1)\fP, \fBtkn\-triggertemplate(1)\fP, \fBtkn\-version(1)\fP
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ require (
github.com/stretchr/testify v1.4.0
github.com/tektoncd/pipeline v0.9.2
github.com/tektoncd/plumbing v0.0.0-20191218171343-56a836c50336
github.com/tektoncd/triggers v0.1.1-0.20191218175743-c5b8b4d9ee00
go.opencensus.io v0.22.1 // indirect
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392 // indirect
golang.org/x/net v0.0.0-20190923162816-aa69164e4478 // indirect
Expand All @@ -50,6 +51,7 @@ require (
k8s.io/client-go v0.0.0-20191004102537-eb5b9a8cfde7
k8s.io/klog v1.0.0 // indirect
k8s.io/kube-openapi v0.0.0-20171101183504-39a7bf85c140 // indirect
knative.dev/caching v0.0.0-20190719140829-2032732871ff // indirect
knative.dev/pkg v0.0.0-20190909195211-528ad1c1dd62
sigs.k8s.io/yaml v1.1.0 // indirect
)
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ github.com/tektoncd/pipeline v0.9.2/go.mod h1:IZzJdiX9EqEMuUcgdnElozdYYRh0/ZRC+N
github.com/tektoncd/plumbing v0.0.0-20191218171343-56a836c50336 h1:gTedwNTH1vMF6wlA6wvQqinpH0ls8G6oQgsaHuuqCGc=
github.com/tektoncd/plumbing v0.0.0-20191218171343-56a836c50336/go.mod h1:QZHgU07PRBTRF6N57w4+ApRu8OgfYLFNqCDlfEZaD9Y=
github.com/tektoncd/plumbing/pipelinerun-logs v0.0.0-20191206114338-712d544c2c21/go.mod h1:S62EUWtqmejjJgUMOGB1CCCHRp6C706laH06BoALkzU=
github.com/tektoncd/triggers v0.1.1-0.20191218175743-c5b8b4d9ee00 h1:3lXGoVjS6unUObcQDZI+LuVRZdBhatvdLxxlhELC/C0=
github.com/tektoncd/triggers v0.1.1-0.20191218175743-c5b8b4d9ee00/go.mod h1:sf5zayuDu6gUI4JsCYDunukfrb1ng/Lz0FoWcJ0cFt4=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
Expand Down Expand Up @@ -402,6 +404,8 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/kube-openapi v0.0.0-20171101183504-39a7bf85c140 h1:j1Zez+Xb4OWvCdROqeq8sP2ACi/qWV1tj/imP0/8a0k=
k8s.io/kube-openapi v0.0.0-20171101183504-39a7bf85c140/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
knative.dev/caching v0.0.0-20190719140829-2032732871ff h1:PrlDvOGvCASqW5Fs3ZGes0ma3P5Wr8nuzlTX+EnqfUg=
knative.dev/caching v0.0.0-20190719140829-2032732871ff/go.mod h1:dHXFU6CGlLlbzaWc32g80cR92iuBSpsslDNBWI8C7eg=
knative.dev/pkg v0.0.0-20190909195211-528ad1c1dd62 h1:0neKnC9hstF5Lewj6OaAJdXqk22IZ7pnOPQ8Zl8cfq4=
knative.dev/pkg v0.0.0-20190909195211-528ad1c1dd62/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/jonboulle/clockwork"
"github.com/tektoncd/pipeline/pkg/client/clientset/versioned"
versionedTriggers "github.com/tektoncd/triggers/pkg/client/clientset/versioned"
k8s "k8s.io/client-go/kubernetes"
)

Expand All @@ -32,6 +33,7 @@ type Stream struct {
type Clients struct {
Tekton versioned.Interface
Kube k8s.Interface
Triggers versionedTriggers.Interface
HTTPClient http.Client
}

Expand Down
20 changes: 18 additions & 2 deletions pkg/cli/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/jonboulle/clockwork"
"github.com/pkg/errors"
"github.com/tektoncd/pipeline/pkg/client/clientset/versioned"
versionedTriggers "github.com/tektoncd/triggers/pkg/client/clientset/versioned"
k8s "k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
)
Expand Down Expand Up @@ -52,6 +53,15 @@ func (p *TektonParams) tektonClient(config *rest.Config) (versioned.Interface, e
return cs, nil
}

func (p *TektonParams) triggersClient(config *rest.Config) (versionedTriggers.Interface, error) {
cs, err := versionedTriggers.NewForConfig(config)
if err != nil {
return nil, err
}

return cs, nil
}

// Set kube client based on config
func (p *TektonParams) kubeClient(config *rest.Config) (k8s.Interface, error) {
k8scs, err := k8s.NewForConfig(config)
Expand Down Expand Up @@ -94,14 +104,20 @@ func (p *TektonParams) Clients() (*Clients, error) {
return nil, err
}

triggers, err := p.triggersClient(config)
if err != nil {
return nil, err
}

kube, err := p.kubeClient(config)
if err != nil {
return nil, err
}

p.clients = &Clients{
Tekton: tekton,
Kube: kube,
Tekton: tekton,
Kube: kube,
Triggers: triggers,
}

return p.clients, nil
Expand Down
8 changes: 5 additions & 3 deletions pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/tektoncd/cli/pkg/cmd/pipelinerun"
"github.com/tektoncd/cli/pkg/cmd/task"
"github.com/tektoncd/cli/pkg/cmd/taskrun"
"github.com/tektoncd/cli/pkg/cmd/triggertemplate"
"github.com/tektoncd/cli/pkg/cmd/version"
)

Expand Down Expand Up @@ -75,14 +76,15 @@ func Root(p cli.Params) *cobra.Command {
cmd.SetUsageTemplate(usageTemplate)

cmd.AddCommand(
clustertask.Command(p),
completion.Command(),
condition.Command(p),
pipeline.Command(p),
pipelineresource.Command(p),
pipelinerun.Command(p),
task.Command(p),
taskrun.Command(p),
pipelineresource.Command(p),
clustertask.Command(p),
condition.Command(p),
triggertemplate.Command(p),
version.Command(),
)

Expand Down
Loading

0 comments on commit 89e99a4

Please sign in to comment.