Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cdsctl): cdsctl template instances #5396

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cli/cdsctl/template_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

var templateInstancesCmd = cli.Command{
Name: "instances",
Aliases: []string{"instances"},
Short: "Get instances for a CDS workflow template",
Example: "cdsctl template instances group-name/template-slug",
OptionalArgs: []cli.Arg{
Expand Down Expand Up @@ -42,6 +43,8 @@ func templateInstancesRun(v cli.Values) (cli.ListResult, error) {
Project string `cli:"project"`
Workflow string `cli:"workflow"`
Params string `cli:"params"`
Version int64 `cli:"version"`
UpToDate bool `cli:"uptodate"`
}

tids := make([]TemplateInstanceDisplay, len(wtis))
Expand All @@ -58,6 +61,8 @@ func templateInstancesRun(v cli.Values) (cli.ListResult, error) {
for k, v := range wtis[i].Request.Parameters {
tids[i].Params = fmt.Sprintf("%s%s:%s\n", tids[i].Params, k, v)
}
tids[i].Version = wtis[i].WorkflowTemplateVersion
tids[i].UpToDate = wtis[i].WorkflowTemplateVersion == wt.Version
}

return cli.AsListResult(tids), nil
Expand Down
10 changes: 10 additions & 0 deletions tests/03_clictl_template_apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,13 @@ testcases:
assertions:
- result.err ShouldEqual ""
- result.md5sum.fixtures_template_simple_export_itcliwkf.yml ShouldEqual "{{.readWorkflowSourceFiles.result.md5sum.fixtures_template_simple_workflow_itcliwkf.yml}}"

- name: cdsctl template instances
steps:
- script: {{.cdsctl}} -f {{.cdsctl.config}} template instances shared.infra/example-simple --format json
assertions:
- result.code ShouldEqual 0
- result.systemoutjson.systemoutjson0.project ShouldEqual "Test Project"
- result.systemoutjson.systemoutjson0.workflow ShouldEqual "ITCLIWKF"
- result.systemoutjson.systemoutjson0.uptodate ShouldEqual "true"
- result.systemoutjson.systemoutjson0.version ShouldEqual "1"