Skip to content

Commit 9557901

Browse files
authored
feat(cdsctl): cdsctl template instances (#5396)
1 parent 7288e75 commit 9557901

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

cli/cdsctl/template_instances.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
var templateInstancesCmd = cli.Command{
1414
Name: "instances",
15+
Aliases: []string{"instances"},
1516
Short: "Get instances for a CDS workflow template",
1617
Example: "cdsctl template instances group-name/template-slug",
1718
OptionalArgs: []cli.Arg{
@@ -42,6 +43,8 @@ func templateInstancesRun(v cli.Values) (cli.ListResult, error) {
4243
Project string `cli:"project"`
4344
Workflow string `cli:"workflow"`
4445
Params string `cli:"params"`
46+
Version int64 `cli:"version"`
47+
UpToDate bool `cli:"uptodate"`
4548
}
4649

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

6368
return cli.AsListResult(tids), nil

tests/03_clictl_template_apply.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,13 @@ testcases:
4242
assertions:
4343
- result.err ShouldEqual ""
4444
- result.md5sum.fixtures_template_simple_export_itcliwkf.yml ShouldEqual "{{.readWorkflowSourceFiles.result.md5sum.fixtures_template_simple_workflow_itcliwkf.yml}}"
45+
46+
- name: cdsctl template instances
47+
steps:
48+
- script: {{.cdsctl}} -f {{.cdsctl.config}} template instances shared.infra/example-simple --format json
49+
assertions:
50+
- result.code ShouldEqual 0
51+
- result.systemoutjson.systemoutjson0.project ShouldEqual "Test Project"
52+
- result.systemoutjson.systemoutjson0.workflow ShouldEqual "ITCLIWKF"
53+
- result.systemoutjson.systemoutjson0.uptodate ShouldEqual "true"
54+
- result.systemoutjson.systemoutjson0.version ShouldEqual "1"

0 commit comments

Comments
 (0)