From 780ecc823a8e61ce2722f266e791a897e670f96c Mon Sep 17 00:00:00 2001 From: Piyush Garg Date: Mon, 23 Dec 2019 17:05:38 +0530 Subject: [PATCH] Add triggerbinding list This will add the command for listing triggerbinding Also add tests and docs Part of #530 --- README.md | 10 +- docs/cmd/tkn.md | 1 + docs/cmd/tkn_triggerbinding.md | 25 ++++ docs/cmd/tkn_triggerbinding_list.md | 49 +++++++ docs/man/man1/tkn-triggerbinding-list.1 | 86 +++++++++++ docs/man/man1/tkn-triggerbinding.1 | 45 ++++++ docs/man/man1/tkn.1 | 2 +- pkg/cmd/root.go | 2 + pkg/cmd/triggerbinding/list.go | 133 ++++++++++++++++++ pkg/cmd/triggerbinding/list_test.go | 131 +++++++++++++++++ pkg/cmd/triggerbinding/triggerbinding.go | 42 ++++++ pkg/cmd/triggerbinding/triggerbinding_test.go | 32 +++++ pkg/test/builder/triggerbinding.go | 30 ++++ 13 files changed, 583 insertions(+), 5 deletions(-) create mode 100644 docs/cmd/tkn_triggerbinding.md create mode 100644 docs/cmd/tkn_triggerbinding_list.md create mode 100644 docs/man/man1/tkn-triggerbinding-list.1 create mode 100644 docs/man/man1/tkn-triggerbinding.1 create mode 100644 pkg/cmd/triggerbinding/list.go create mode 100644 pkg/cmd/triggerbinding/list_test.go create mode 100644 pkg/cmd/triggerbinding/triggerbinding.go create mode 100644 pkg/cmd/triggerbinding/triggerbinding_test.go create mode 100644 pkg/test/builder/triggerbinding.go diff --git a/README.md b/README.md index 6cd58c9aa..cc5fdc641 100644 --- a/README.md +++ b/README.md @@ -137,15 +137,17 @@ $ ./kubectl plugin list The following commands help you understand and effectively use the Tekton CLI: * `tkn help:` Displays a list of the commands with helpful information. + * [`tkn clustertask:`](docs/cmd/tkn_clustertask.md) Parent command of the ClusterTask command group. * [`tkn completion:`](docs/cmd/tkn_completion.md) Outputs a BASH or ZSH completion script for `tkn` to allow command completion with Tab. - * [`tkn version:`](docs/cmd/tkn_version.md) Outputs the cli version. + * [`tkn condition:`](docs/cmd/tkn_condition.md) Parent command of the Condition command group. * [`tkn pipeline:`](docs/cmd/tkn_pipeline.md) Parent command of the Pipeline command group. * [`tkn pipelinerun:`](docs/cmd/tkn_pipelinerun.md) Parent command of the Pipelinerun command group. + * [`tkn resource:`](docs/cmd/tkn_resource.md) Parent command of the Resource command group. * [`tkn task:`](docs/cmd/tkn_task.md) Parent command of the Task command group. * [`tkn taskrun:`](docs/cmd/tkn_taskrun.md) Parent command of the Taskrun command group. - * [`tkn clustertask:`](docs/cmd/tkn_clustertask.md) Parent command of the ClusterTask command group. - * [`tkn resource:`](docs/cmd/tkn_resource.md) Parent command of the Resource command group. - * [`tkn condition:`](docs/cmd/tkn_condition.md) Parent command of the Condition command group. + * [`tkn triggerbinding:`](docs/cmd/tkn_triggerbinding.md) Parent command of the Triggerbinding command group. + * [`tkn triggertemplate:`](docs/cmd/tkn_triggertemplate.md) Parent command of the Triggertemplate command group. + * [`tkn version:`](docs/cmd/tkn_version.md) Outputs the cli version. For every `tkn` command, you can use `-h` or `--help` flags to display specific help for that command. diff --git a/docs/cmd/tkn.md b/docs/cmd/tkn.md index 4a9b9a705..344e94658 100644 --- a/docs/cmd/tkn.md +++ b/docs/cmd/tkn.md @@ -22,6 +22,7 @@ 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 triggerbinding](tkn_triggerbinding.md) - Manage triggerbindings * [tkn triggertemplate](tkn_triggertemplate.md) - Manage triggertemplates * [tkn version](tkn_version.md) - Prints version information diff --git a/docs/cmd/tkn_triggerbinding.md b/docs/cmd/tkn_triggerbinding.md new file mode 100644 index 000000000..b6f4ce545 --- /dev/null +++ b/docs/cmd/tkn_triggerbinding.md @@ -0,0 +1,25 @@ +## tkn triggerbinding + +Manage triggerbindings + +***Aliases**: tb,triggerbindings* + +### Synopsis + +Manage triggerbindings + +### Options + +``` + -c, --context string name of the kubeconfig context to use (default: kubectl config current-context) + -h, --help help for triggerbinding + -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 triggerbinding list](tkn_triggerbinding_list.md) - Lists triggerbindings in a namespace + diff --git a/docs/cmd/tkn_triggerbinding_list.md b/docs/cmd/tkn_triggerbinding_list.md new file mode 100644 index 000000000..0f6764b25 --- /dev/null +++ b/docs/cmd/tkn_triggerbinding_list.md @@ -0,0 +1,49 @@ +## tkn triggerbinding list + +Lists triggerbindings in a namespace + +***Aliases**: ls* + +### Usage + +``` +tkn triggerbinding list +``` + +### Synopsis + +Lists triggerbindings in a namespace + +### Examples + +List all triggerbindings in namespace 'bar': + + tkn triggerbinding list -n bar + +or + + tkn tb 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 triggerbinding](tkn_triggerbinding.md) - Manage triggerbindings + diff --git a/docs/man/man1/tkn-triggerbinding-list.1 b/docs/man/man1/tkn-triggerbinding-list.1 new file mode 100644 index 000000000..f1e25f9fc --- /dev/null +++ b/docs/man/man1/tkn-triggerbinding-list.1 @@ -0,0 +1,86 @@ +.TH "TKN\-TRIGGERBINDING\-LIST" "1" "" "Auto generated by spf13/cobra" "" +.nh +.ad l + + +.SH NAME +.PP +tkn\-triggerbinding\-list \- Lists triggerbindings in a namespace + + +.SH SYNOPSIS +.PP +\fBtkn triggerbinding list\fP + + +.SH DESCRIPTION +.PP +Lists triggerbindings 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 triggerbindings in namespace 'bar': + +.PP +.RS + +.nf +tkn triggerbinding list \-n bar + +.fi +.RE + +.PP +or + +.PP +.RS + +.nf +tkn tb ls \-n bar + +.fi +.RE + + +.SH SEE ALSO +.PP +\fBtkn\-triggerbinding(1)\fP diff --git a/docs/man/man1/tkn-triggerbinding.1 b/docs/man/man1/tkn-triggerbinding.1 new file mode 100644 index 000000000..ffa4df0cc --- /dev/null +++ b/docs/man/man1/tkn-triggerbinding.1 @@ -0,0 +1,45 @@ +.TH "TKN\-TRIGGERBINDING" "1" "" "Auto generated by spf13/cobra" "" +.nh +.ad l + + +.SH NAME +.PP +tkn\-triggerbinding \- Manage triggerbindings + + +.SH SYNOPSIS +.PP +\fBtkn triggerbinding\fP + + +.SH DESCRIPTION +.PP +Manage triggerbindings + + +.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 triggerbinding + +.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\-triggerbinding\-list(1)\fP diff --git a/docs/man/man1/tkn.1 b/docs/man/man1/tkn.1 index 603fefdb2..388f45e0b 100644 --- a/docs/man/man1/tkn.1 +++ b/docs/man/man1/tkn.1 @@ -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\-triggertemplate(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\-triggerbinding(1)\fP, \fBtkn\-triggertemplate(1)\fP, \fBtkn\-version(1)\fP diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index f9f117d9d..435bb9d85 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -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/triggerbinding" "github.com/tektoncd/cli/pkg/cmd/triggertemplate" "github.com/tektoncd/cli/pkg/cmd/version" ) @@ -84,6 +85,7 @@ func Root(p cli.Params) *cobra.Command { pipelinerun.Command(p), task.Command(p), taskrun.Command(p), + triggerbinding.Command(p), triggertemplate.Command(p), version.Command(), ) diff --git a/pkg/cmd/triggerbinding/list.go b/pkg/cmd/triggerbinding/list.go new file mode 100644 index 000000000..71f24ab2d --- /dev/null +++ b/pkg/cmd/triggerbinding/list.go @@ -0,0 +1,133 @@ +// Copyright © 2019 The Tekton Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package triggerbinding + +import ( + "errors" + "fmt" + "text/tabwriter" + + "github.com/spf13/cobra" + "github.com/tektoncd/cli/pkg/cli" + "github.com/tektoncd/cli/pkg/formatted" + "github.com/tektoncd/cli/pkg/helper/validate" + "github.com/tektoncd/cli/pkg/printer" + "github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1" + "github.com/tektoncd/triggers/pkg/client/clientset/versioned" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + cliopts "k8s.io/cli-runtime/pkg/genericclioptions" +) + +const ( + emptyMsg = "No triggerbindings found" +) + +func listCommand(p cli.Params) *cobra.Command { + f := cliopts.NewPrintFlags("list") + + eg := `List all triggerbindings in namespace 'bar': + + tkn triggerbinding list -n bar + +or + + tkn tb ls -n bar +` + + c := &cobra.Command{ + Use: "list", + Aliases: []string{"ls"}, + Short: "Lists triggerbindings in a namespace", + Annotations: map[string]string{ + "commandType": "main", + }, + Example: eg, + RunE: func(cmd *cobra.Command, args []string) error { + if err := validate.NamespaceExists(p); err != nil { + return err + } + + cs, err := p.Clients() + if err != nil { + return err + } + + tbs, err := list(cs.Triggers, p.Namespace()) + if err != nil { + return fmt.Errorf(`failed to list triggerbindings from %s namespace \n`, p.Namespace()) + } + + output, err := cmd.LocalFlags().GetString("output") + if err != nil { + return errors.New(`output option not set properly \n`) + } + + stream := &cli.Stream{ + Out: cmd.OutOrStdout(), + Err: cmd.OutOrStderr(), + } + + if output != "" { + return printer.PrintObject(stream.Out, tbs, f) + } + + if err = printFormatted(stream, tbs, p); err != nil { + return errors.New(`failed to print triggerbindings \n`) + } + return nil + + }, + } + + f.AddFlags(c) + + return c +} + +func list(client versioned.Interface, namespace string) (*v1alpha1.TriggerBindingList, error) { + tbs, err := client.TektonV1alpha1().TriggerBindings(namespace).List(metav1.ListOptions{}) + if err != nil { + return nil, err + } + + // NOTE: this is required for -o json|yaml to work properly since + // tektoncd go client fails to set these; probably a bug + tbs.GetObjectKind().SetGroupVersionKind( + schema.GroupVersionKind{ + Version: "tekton.dev/v1alpha1", + Kind: "TriggerBindingList", + }) + + return tbs, nil +} + +func printFormatted(s *cli.Stream, tbs *v1alpha1.TriggerBindingList, p cli.Params) error { + if len(tbs.Items) == 0 { + fmt.Fprintln(s.Err, emptyMsg) + return nil + } + + w := tabwriter.NewWriter(s.Out, 0, 5, 3, ' ', tabwriter.TabIndent) + fmt.Fprintln(w, "NAME\tAGE") + for _, tb := range tbs.Items { + fmt.Fprintf(w, "%s\t%s\n", + tb.Name, + formatted.Age(&tb.CreationTimestamp, p.Time()), + ) + } + + return w.Flush() +} diff --git a/pkg/cmd/triggerbinding/list_test.go b/pkg/cmd/triggerbinding/list_test.go new file mode 100644 index 000000000..a04cccd5c --- /dev/null +++ b/pkg/cmd/triggerbinding/list_test.go @@ -0,0 +1,131 @@ +// Copyright © 2019 The Tekton Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package triggerbinding + +import ( + "strings" + "testing" + "time" + + "github.com/jonboulle/clockwork" + "github.com/spf13/cobra" + "github.com/tektoncd/cli/pkg/test" + cb "github.com/tektoncd/cli/pkg/test/builder" + "github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1" + triggertest "github.com/tektoncd/triggers/test" + tb "github.com/tektoncd/triggers/test/builder" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func TestListTriggerBinding(t *testing.T) { + now := time.Now() + + ns := []*corev1.Namespace{ + { + ObjectMeta: metav1.ObjectMeta{ + Name: "foo", + }, + }, + { + ObjectMeta: metav1.ObjectMeta{ + Name: "random", + }, + }, + } + + tbs := []*v1alpha1.TriggerBinding{ + tb.TriggerBinding("tb1", "foo", cb.TriggerBindingCreationTime(now.Add(-2*time.Minute))), + tb.TriggerBinding("tb2", "foo", cb.TriggerBindingCreationTime(now.Add(-30*time.Second))), + tb.TriggerBinding("tb3", "foo", cb.TriggerBindingCreationTime(now.Add(-200*time.Hour))), + tb.TriggerBinding("tb4", "foo"), + } + + tests := []struct { + name string + command *cobra.Command + args []string + expected []string + wantError bool + }{ + { + name: "Invalid namespace", + command: command(t, tbs, now, ns), + args: []string{"list", "-n", "default"}, + expected: []string{ + "Error: namespaces \"default\" not found\n", + }, + wantError: true, + }, + { + name: "No TriggerBinding", + command: command(t, tbs, now, ns), + args: []string{"list", "-n", "random"}, + expected: []string{ + "No triggerbindings found\n", + }, + wantError: false, + }, + { + name: "Multiple TriggerBinding", + command: command(t, tbs, now, ns), + args: []string{"list", "-n", "foo"}, + expected: []string{ + "NAME AGE", + "tb1 2 minutes ago", + "tb2 30 seconds ago", + "tb3 1 week ago", + "tb4 ---", + "", + }, + wantError: false, + }, + { + name: "Multiple TriggerBinding with output format", + command: command(t, tbs, now, ns), + args: []string{"list", "-n", "foo", "-o", "jsonpath={range .items[*]}{.metadata.name}{\"\\n\"}{end}"}, + expected: []string{ + "tb1", + "tb2", + "tb3", + "tb4", + "", + }, + wantError: false, + }, + } + + for _, td := range tests { + t.Run(td.name, func(t *testing.T) { + got, err := test.ExecuteCommand(td.command, td.args...) + + if err != nil && !td.wantError { + t.Errorf("Unexpected error: %v", err) + } + test.AssertOutput(t, strings.Join(td.expected, "\n"), got) + }) + } +} + +func command(t *testing.T, tbs []*v1alpha1.TriggerBinding, now time.Time, ns []*corev1.Namespace) *cobra.Command { + // fake clock advanced by 1 hour + clock := clockwork.NewFakeClockAt(now) + + cs := test.SeedTestResources(t, triggertest.Resources{TriggerBindings: tbs, Namespaces: ns}) + + p := &test.Params{Tekton: cs.Pipeline, Clock: clock, Kube: cs.Kube, Triggers: cs.Triggers} + + return Command(p) +} diff --git a/pkg/cmd/triggerbinding/triggerbinding.go b/pkg/cmd/triggerbinding/triggerbinding.go new file mode 100644 index 000000000..17b30b9d4 --- /dev/null +++ b/pkg/cmd/triggerbinding/triggerbinding.go @@ -0,0 +1,42 @@ +// Copyright © 2019 The Tekton Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package triggerbinding + +import ( + "github.com/spf13/cobra" + "github.com/tektoncd/cli/pkg/cli" + "github.com/tektoncd/cli/pkg/flags" +) + +func Command(p cli.Params) *cobra.Command { + cmd := &cobra.Command{ + Use: "triggerbinding", + Aliases: []string{"tb", "triggerbindings"}, + Short: "Manage triggerbindings", + Annotations: map[string]string{ + "commandType": "main", + }, + PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + return flags.InitParams(p, cmd) + }, + } + + flags.AddTektonOptions(cmd) + cmd.AddCommand( + listCommand(p), + ) + + return cmd +} diff --git a/pkg/cmd/triggerbinding/triggerbinding_test.go b/pkg/cmd/triggerbinding/triggerbinding_test.go new file mode 100644 index 000000000..17490e7fe --- /dev/null +++ b/pkg/cmd/triggerbinding/triggerbinding_test.go @@ -0,0 +1,32 @@ +// Copyright © 2019 The Tekton Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package triggerbinding + +import ( + "testing" + + "github.com/tektoncd/cli/pkg/test" +) + +func TestTriggerBinding_invalid(t *testing.T) { + + p := &test.Params{} + + tb := Command(p) + out, err := test.ExecuteCommand(tb, "foobar") + if err == nil { + t.Errorf("No errors was defined. Output: %s", out) + } +} diff --git a/pkg/test/builder/triggerbinding.go b/pkg/test/builder/triggerbinding.go new file mode 100644 index 000000000..73db6ad4a --- /dev/null +++ b/pkg/test/builder/triggerbinding.go @@ -0,0 +1,30 @@ +// Copyright © 2019 The Tekton Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package builder + +import ( + "time" + + "github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1" + tb "github.com/tektoncd/triggers/test/builder" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// TriggerBindingCreationTime sets CreationTimestamp of the TriggerBinding +func TriggerBindingCreationTime(t time.Time) tb.TriggerBindingOp { + return func(triggerbinding *v1alpha1.TriggerBinding) { + triggerbinding.CreationTimestamp = metav1.Time{Time: t} + } +}