feat : add structured JSON input for start commands#2925
feat : add structured JSON input for start commands#2925vikashkumar2020 wants to merge 3 commits into
Conversation
|
is it possible to add json output too ? |
pipeline : cmd
output |
There was a problem hiding this comment.
Pull request overview
Adds a new --json flag to tkn task start and tkn pipeline start so users can provide structured JSON to populate parts of the generated TaskRun/PipelineRun spec (supporting inline JSON, stdin via -, and file via @path). This fits into the CLI’s start-command workflow by augmenting the existing flag/interactive inputs and updating the generated docs accordingly.
Changes:
- Introduces
--jsonflag handling in task/pipeline start commands (inline / stdin /@file). - Merges selected JSON
*RunSpecfields into the generatedTaskRun/PipelineRunobjects and skips interactive prompting when--jsonis set. - Adds unit/integration-style tests and updates generated markdown + manpage docs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/cmd/task/start.go | Adds --json flag, JSON resolution, and merges JSON spec fields into TaskRun. |
| pkg/cmd/task/start_test.go | Adds coverage for --json (inline/malformed/missing file) plus readJSONSpec tests. |
| pkg/cmd/pipeline/start.go | Adds --json flag, JSON resolution, and merges JSON spec fields into PipelineRun. |
| pkg/cmd/pipeline/start_test.go | Adds coverage for --json (inline/malformed/missing file) plus readJSONSpec tests. |
| docs/man/man1/tkn-task-start.1 | Documents new --json flag for task start. |
| docs/man/man1/tkn-pipeline-start.1 | Documents new --json flag for pipeline start. |
| docs/cmd/tkn_task_start.md | Updates generated markdown docs with --json. |
| docs/cmd/tkn_pipeline_start.md | Updates generated markdown docs with --json. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if opt.JSONSpec != "" { | ||
| if err := applyTaskRunJSONSpec(tr, opt.JSONSpec, os.Stdin); err != nil { | ||
| return err | ||
| } | ||
| } |
| c.Flags().BoolVarP(&opt.UseParamDefaults, "use-param-defaults", "", false, "use default parameter values without prompting for input") | ||
| c.Flags().StringVar(&opt.PodTemplate, "pod-template", "", "local or remote file containing a PodTemplate definition") | ||
| c.Flags().BoolVarP(&opt.SkipOptionalWorkspace, "skip-optional-workspace", "", false, "skips the prompt for optional workspaces") | ||
| c.Flags().StringVar(&opt.JSONSpec, "json", "", "TaskRun spec as JSON (inline, '-' for stdin, or '@path' for a file)") |
| }, | ||
| ) | ||
|
|
||
| c.Flags().StringVar(&opt.JSONSpec, "json", "", "PipelineRun spec as JSON (inline, '-' for stdin, or '@path' for a file)") |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Changes
Add a --json flag to tkn pipeline start and tkn task start so users can provide a PipelineRunSpec or TaskRunSpec as JSON.
The flag supports:
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
make checkmake generatedSee the contribution guide
for more details.
Release Notes