Skip to content

Commit

Permalink
feat(cdsctl): cdsctl template instances (#5396)
Browse files Browse the repository at this point in the history
  • Loading branch information
yesnault authored Aug 27, 2020
1 parent 7288e75 commit 9557901
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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"

0 comments on commit 9557901

Please sign in to comment.