From 9fa002679af8c19095f5ae228aa78c28e8e6c87b Mon Sep 17 00:00:00 2001 From: Yvonnick Esnault Date: Tue, 25 Aug 2020 17:38:35 +0200 Subject: [PATCH] feat(cdsctl): cdsctl template instances add version and status attributes Signed-off-by: Yvonnick Esnault --- cli/cdsctl/template_instances.go | 5 +++++ tests/03_clictl_template_apply.yml | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/cli/cdsctl/template_instances.go b/cli/cdsctl/template_instances.go index 3a51191ccf..bc56916b24 100644 --- a/cli/cdsctl/template_instances.go +++ b/cli/cdsctl/template_instances.go @@ -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{ @@ -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)) @@ -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 diff --git a/tests/03_clictl_template_apply.yml b/tests/03_clictl_template_apply.yml index 4c8d25be95..502ea080d6 100644 --- a/tests/03_clictl_template_apply.yml +++ b/tests/03_clictl_template_apply.yml @@ -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"