From b6be542e1428f5df609d9ef8a606ad115addcf32 Mon Sep 17 00:00:00 2001 From: mattmelgard Date: Wed, 28 Apr 2021 13:14:56 -0600 Subject: [PATCH 1/3] Add support for packId in codefresh pipeline --- client/pipeline.go | 1 + codefresh/resource_pipeline.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/client/pipeline.go b/client/pipeline.go index c91ddbd..7ae6f6f 100644 --- a/client/pipeline.go +++ b/client/pipeline.go @@ -94,6 +94,7 @@ type Spec struct { TerminationPolicy []map[string]interface{} `json:"terminationPolicy,omitempty"` Hooks *Hooks `json:"hooks,omitempty"` Options map[string]bool `json:"options,omitempty"` + PackId string `json:"packId,omitempty"` } type Steps struct { diff --git a/codefresh/resource_pipeline.go b/codefresh/resource_pipeline.go index 822e467..83cfb49 100644 --- a/codefresh/resource_pipeline.go +++ b/codefresh/resource_pipeline.go @@ -79,6 +79,10 @@ func resourcePipeline() *schema.Resource { Optional: true, Default: 0, // zero is unlimited }, + "pack_id": { + Type: schema.TypeString, + Optional: true, + }, "spec_template": { Type: schema.TypeList, Optional: true, @@ -508,6 +512,7 @@ func flattenSpec(spec cfClient.Spec) []interface{} { m["concurrency"] = spec.Concurrency m["branch_concurrency"] = spec.BranchConcurrency m["trigger_concurrency"] = spec.TriggerConcurrency + m["pack_id"] = spec.PackId m["priority"] = spec.Priority @@ -637,6 +642,7 @@ func mapResourceToPipeline(d *schema.ResourceData) *cfClient.Pipeline { Concurrency: d.Get("spec.0.concurrency").(int), BranchConcurrency: d.Get("spec.0.branch_concurrency").(int), TriggerConcurrency: d.Get("spec.0.trigger_concurrency").(int), + PackId: d.Get("spec.0.pack_id").(string), }, } From 4c987ae1156a82b9211478b17713a292c971d332 Mon Sep 17 00:00:00 2001 From: mattmelgard Date: Wed, 28 Apr 2021 13:27:09 -0600 Subject: [PATCH 2/3] Update tests --- codefresh/resource_pipeline_test.go | 52 ++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/codefresh/resource_pipeline_test.go b/codefresh/resource_pipeline_test.go index 7cb9423..ff2efc2 100644 --- a/codefresh/resource_pipeline_test.go +++ b/codefresh/resource_pipeline_test.go @@ -77,6 +77,31 @@ func TestAccCodefreshPipeline_Concurrency(t *testing.T) { }) } +func TestAccCodefreshPipeline_PackId(t *testing.T) { + name := pipelineNamePrefix + acctest.RandString(10) + resourceName := "codefresh_pipeline.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckCodefreshPipelineDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCodefreshPipelineBasicConfigPackId(name, "codefresh-contrib/react-sample-app", "./codefresh.yml", "master", "git", "1"), + Check: resource.ComposeTestCheckFunc( + testAccCheckCodefreshPipelineExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "spec.0.packId", "1"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccCodefreshPipeline_Tags(t *testing.T) { name := pipelineNamePrefix + acctest.RandString(10) resourceName := "codefresh_pipeline.test" @@ -585,7 +610,7 @@ resource "codefresh_pipeline" "test" { `, rName, repo, path, revision, context) } -func testAccCodefreshPipelineBasicConfigTags(rName, repo, path, revision, context, tag1, tag2 string) string { +func testAccCodefreshPipelineBasicConfigPackId(rName, repo, path, revision, context, packId string) string { return fmt.Sprintf(` resource "codefresh_pipeline" "test" { @@ -603,6 +628,31 @@ resource "codefresh_pipeline" "test" { path = %q revision = %q context = %q + packId = %q + } + } +} +`, rName, repo, path, revision, context, packId) +} + +func testAccCodefreshPipelineBasicConfigTags(rName, repo, path, revision, context, tag1, tag2 string) string { + return fmt.Sprintf(` +resource "codefresh_pipeline" "test" { + + lifecycle { + ignore_changes = [ + revision + ] + } + + name = "%s" + + spec { + spec_template { + repo = %q + path = %q + revision = %q + context = %q } } From ac02e5b8d86a8cfc9c5d5a5186afd476245ae06d Mon Sep 17 00:00:00 2001 From: mattmelgard Date: Wed, 3 Nov 2021 10:30:18 -0600 Subject: [PATCH 3/3] Run go fmt as required by tests --- tools.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tools.go b/tools.go index 23cb7bc..e139785 100644 --- a/tools.go +++ b/tools.go @@ -1,3 +1,4 @@ +//go:build tools // +build tools package main