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

Support for specifying spec.packId on codefresh pipeline #44

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions client/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions codefresh/resource_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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),
},
}

Expand Down
52 changes: 51 additions & 1 deletion codefresh/resource_pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" {

Expand All @@ -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
}
}

Expand Down
1 change: 1 addition & 0 deletions tools.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build tools
// +build tools

package main
Expand Down