Skip to content

Commit

Permalink
Make the resource and param input interactively
Browse files Browse the repository at this point in the history
This will add the feature of resource and
param input interactively based on the pipeline
spec.

If user has privded resource or param input
by flag then interactive terminal will not start

Also support param as both array and string

Add respective test and docs
  • Loading branch information
piyush-garg authored and tekton-robot committed Sep 3, 2019
1 parent 2c437af commit 147cb1d
Show file tree
Hide file tree
Showing 5 changed files with 631 additions and 94 deletions.
4 changes: 2 additions & 2 deletions docs/cmd/tkn_pipeline_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ two parameters (foo and bar)
```
-h, --help help for start
-l, --last re-run the pipeline using last pipelinerun values
-p, --param strings pass the param
-r, --resource strings pass the resource name and ref
-p, --param strings pass the param as key=value
-r, --resource strings pass the resource name and ref as name=ref
-s, --serviceaccount string pass the serviceaccount name
--task-serviceaccount strings pass the service account corresponding to the task
```
Expand Down
4 changes: 2 additions & 2 deletions docs/man/man1/tkn-pipeline-start.1
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ Parameters, at least those that have no default value

.PP
\fB\-p\fP, \fB\-\-param\fP=[]
pass the param
pass the param as key=value

.PP
\fB\-r\fP, \fB\-\-resource\fP=[]
pass the resource name and ref
pass the resource name and ref as name=ref

.PP
\fB\-s\fP, \fB\-\-serviceaccount\fP=""
Expand Down
19 changes: 19 additions & 0 deletions pkg/cmd/pipeline/logs_testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/AlecAivazis/survey/v2/terminal"
"github.com/Netflix/go-expect"
"github.com/stretchr/testify/require"
"github.com/tektoncd/cli/pkg/cli"
)

type promptTest struct {
Expand All @@ -46,6 +47,24 @@ func (opts *logOptions) RunPromptTest(t *testing.T, test promptTest) {
})
}

func (opts *startOptions) RunPromptTest(t *testing.T, test promptTest) {

test.runTest(t, test.procedure, func(stdio terminal.Stdio) error {
var err error
opts.askOpts = WithStdio(stdio)
opts.stream = &cli.Stream{
Out: stdio.Out,
Err: stdio.Err,
}
err = opts.run(test.cmdArgs[0])
if err != nil {
return err
}

return err
})
}

func stdio(c *expect.Console) terminal.Stdio {
return terminal.Stdio{In: c.Tty(), Out: c.Tty(), Err: c.Tty()}
}
Expand Down
Loading

0 comments on commit 147cb1d

Please sign in to comment.