Skip to content

Commit 147cb1d

Browse files
piyush-gargtekton-robot
authored andcommitted
Make the resource and param input interactively
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
1 parent 2c437af commit 147cb1d

File tree

5 files changed

+631
-94
lines changed

5 files changed

+631
-94
lines changed

docs/cmd/tkn_pipeline_start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ two parameters (foo and bar)
3838
```
3939
-h, --help help for start
4040
-l, --last re-run the pipeline using last pipelinerun values
41-
-p, --param strings pass the param
42-
-r, --resource strings pass the resource name and ref
41+
-p, --param strings pass the param as key=value
42+
-r, --resource strings pass the resource name and ref as name=ref
4343
-s, --serviceaccount string pass the serviceaccount name
4444
--task-serviceaccount strings pass the service account corresponding to the task
4545
```

docs/man/man1/tkn-pipeline-start.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ Parameters, at least those that have no default value
3737

3838
.PP
3939
\fB\-p\fP, \fB\-\-param\fP=[]
40-
pass the param
40+
pass the param as key=value
4141

4242
.PP
4343
\fB\-r\fP, \fB\-\-resource\fP=[]
44-
pass the resource name and ref
44+
pass the resource name and ref as name=ref
4545

4646
.PP
4747
\fB\-s\fP, \fB\-\-serviceaccount\fP=""

pkg/cmd/pipeline/logs_testutil.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/AlecAivazis/survey/v2/terminal"
2525
"github.com/Netflix/go-expect"
2626
"github.com/stretchr/testify/require"
27+
"github.com/tektoncd/cli/pkg/cli"
2728
)
2829

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

50+
func (opts *startOptions) RunPromptTest(t *testing.T, test promptTest) {
51+
52+
test.runTest(t, test.procedure, func(stdio terminal.Stdio) error {
53+
var err error
54+
opts.askOpts = WithStdio(stdio)
55+
opts.stream = &cli.Stream{
56+
Out: stdio.Out,
57+
Err: stdio.Err,
58+
}
59+
err = opts.run(test.cmdArgs[0])
60+
if err != nil {
61+
return err
62+
}
63+
64+
return err
65+
})
66+
}
67+
4968
func stdio(c *expect.Console) terminal.Stdio {
5069
return terminal.Stdio{In: c.Tty(), Out: c.Tty(), Err: c.Tty()}
5170
}

0 commit comments

Comments
 (0)