diff --git a/client/pipeline.go b/client/pipeline.go index a65f111..ed14da0 100644 --- a/client/pipeline.go +++ b/client/pipeline.go @@ -19,6 +19,7 @@ type Labels struct { type Metadata struct { Name string `json:"name,omitempty"` ID string `json:"id,omitempty"` + IsPublic bool `json:"isPublic,omitempty"` Labels Labels `json:"labels,omitempty"` OriginalYamlString string `json:"originalYamlString,omitempty"` Project string `json:"project,omitempty"` diff --git a/codefresh/resource_pipeline.go b/codefresh/resource_pipeline.go index e02b93c..86f7af1 100644 --- a/codefresh/resource_pipeline.go +++ b/codefresh/resource_pipeline.go @@ -37,6 +37,11 @@ func resourcePipeline() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "is_public": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, "revision": { Type: schema.TypeInt, Computed: true, @@ -392,6 +397,11 @@ func mapPipelineToResource(pipeline cfClient.Pipeline, d *schema.ResourceData) e return err } + err = d.Set("is_public", pipeline.Metadata.IsPublic) + if err != nil { + return err + } + err = d.Set("spec", flattenSpec(pipeline.Spec)) if err != nil { return err @@ -542,6 +552,7 @@ func mapResourceToPipeline(d *schema.ResourceData) *cfClient.Pipeline { Name: d.Get("name").(string), Revision: d.Get("revision").(int), ProjectId: d.Get("project_id").(string), + IsPublic: d.Get("is_public").(bool), Labels: cfClient.Labels{ Tags: convertStringArr(tags), }, diff --git a/codefresh/resource_pipeline_test.go b/codefresh/resource_pipeline_test.go index 861b7c4..a08ca82 100644 --- a/codefresh/resource_pipeline_test.go +++ b/codefresh/resource_pipeline_test.go @@ -311,6 +311,38 @@ func TestAccCodefreshPipeline_Revision(t *testing.T) { }) } +func TestAccCodefreshPipeline_IsPublic(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: testAccCodefreshPipelineBasicConfig(name, "codefresh-contrib/react-sample-app", "./codefresh.yml", "master", "git"), + Check: resource.ComposeTestCheckFunc( + testAccCheckCodefreshPipelineExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "is_public", "false"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccCodefreshPipelineIsPublic(name, "codefresh-contrib/react-sample-app", "./codefresh.yml", "development", "git", true), + Check: resource.ComposeTestCheckFunc( + testAccCheckCodefreshPipelineExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "is_public", "true"), + ), + }, + }, + }) +} + func TestAccCodefreshPipelineOnCreateBranchIgnoreTrigger(t *testing.T) { name := pipelineNamePrefix + acctest.RandString(10) resourceName := "codefresh_pipeline.test" @@ -584,7 +616,7 @@ resource "codefresh_pipeline" "test" { branch_regex_input = %q pull_request_target_branch_regex = %q comment_regex = %q - + context = %q contexts = [ %q @@ -791,3 +823,30 @@ resource "codefresh_pipeline" "test" { } `, rName, repo, path, revision, context, branchName, ignoreTrigger) } + +func testAccCodefreshPipelineIsPublic(rName, repo, path, revision, context string, isPublic bool) 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 + } + } + + is_public = %t + +} +`, rName, repo, path, revision, context, isPublic) +} diff --git a/docs/resources/pipeline.md b/docs/resources/pipeline.md index 37d4bce..39c0944 100644 --- a/docs/resources/pipeline.md +++ b/docs/resources/pipeline.md @@ -87,6 +87,7 @@ resource "codefresh_pipeline" "test" { - `name` - (Required) The display name for the pipeline. - `revision` - (Optional) The pipeline's revision. Should be added to the **lifecycle/ignore_changes** or incremented mannually each update. +- `is_public` - (Optional) Boolean that specifies if the build logs are publicly accessible. Default: false - `tags` - (Optional) A list of tags to mark a project for easy management and access control. - `spec` - (Required) A collection of `spec` blocks as documented below. - `original_yaml_string` - (Optional) A string with original yaml pipeline.