Skip to content

Commit 0b732c2

Browse files
Merge pull request #34 from sandrogattuso/feature/is_public
Add support for isPublic attribute in pipelines
2 parents 7c53585 + 4f8421b commit 0b732c2

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

client/pipeline.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Labels struct {
1919
type Metadata struct {
2020
Name string `json:"name,omitempty"`
2121
ID string `json:"id,omitempty"`
22+
IsPublic bool `json:"isPublic,omitempty"`
2223
Labels Labels `json:"labels,omitempty"`
2324
OriginalYamlString string `json:"originalYamlString,omitempty"`
2425
Project string `json:"project,omitempty"`

codefresh/resource_pipeline.go

+11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ func resourcePipeline() *schema.Resource {
3737
Type: schema.TypeString,
3838
Computed: true,
3939
},
40+
"is_public": {
41+
Type: schema.TypeBool,
42+
Optional: true,
43+
Default: false,
44+
},
4045
"revision": {
4146
Type: schema.TypeInt,
4247
Computed: true,
@@ -392,6 +397,11 @@ func mapPipelineToResource(pipeline cfClient.Pipeline, d *schema.ResourceData) e
392397
return err
393398
}
394399

400+
err = d.Set("is_public", pipeline.Metadata.IsPublic)
401+
if err != nil {
402+
return err
403+
}
404+
395405
err = d.Set("spec", flattenSpec(pipeline.Spec))
396406
if err != nil {
397407
return err
@@ -542,6 +552,7 @@ func mapResourceToPipeline(d *schema.ResourceData) *cfClient.Pipeline {
542552
Name: d.Get("name").(string),
543553
Revision: d.Get("revision").(int),
544554
ProjectId: d.Get("project_id").(string),
555+
IsPublic: d.Get("is_public").(bool),
545556
Labels: cfClient.Labels{
546557
Tags: convertStringArr(tags),
547558
},

codefresh/resource_pipeline_test.go

+60-1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,38 @@ func TestAccCodefreshPipeline_Revision(t *testing.T) {
311311
})
312312
}
313313

314+
func TestAccCodefreshPipeline_IsPublic(t *testing.T) {
315+
name := pipelineNamePrefix + acctest.RandString(10)
316+
resourceName := "codefresh_pipeline.test"
317+
318+
resource.ParallelTest(t, resource.TestCase{
319+
PreCheck: func() { testAccPreCheck(t) },
320+
Providers: testAccProviders,
321+
CheckDestroy: testAccCheckCodefreshPipelineDestroy,
322+
Steps: []resource.TestStep{
323+
{
324+
Config: testAccCodefreshPipelineBasicConfig(name, "codefresh-contrib/react-sample-app", "./codefresh.yml", "master", "git"),
325+
Check: resource.ComposeTestCheckFunc(
326+
testAccCheckCodefreshPipelineExists(resourceName),
327+
resource.TestCheckResourceAttr(resourceName, "is_public", "false"),
328+
),
329+
},
330+
{
331+
ResourceName: resourceName,
332+
ImportState: true,
333+
ImportStateVerify: true,
334+
},
335+
{
336+
Config: testAccCodefreshPipelineIsPublic(name, "codefresh-contrib/react-sample-app", "./codefresh.yml", "development", "git", true),
337+
Check: resource.ComposeTestCheckFunc(
338+
testAccCheckCodefreshPipelineExists(resourceName),
339+
resource.TestCheckResourceAttr(resourceName, "is_public", "true"),
340+
),
341+
},
342+
},
343+
})
344+
}
345+
314346
func TestAccCodefreshPipelineOnCreateBranchIgnoreTrigger(t *testing.T) {
315347
name := pipelineNamePrefix + acctest.RandString(10)
316348
resourceName := "codefresh_pipeline.test"
@@ -584,7 +616,7 @@ resource "codefresh_pipeline" "test" {
584616
branch_regex_input = %q
585617
pull_request_target_branch_regex = %q
586618
comment_regex = %q
587-
619+
588620
context = %q
589621
contexts = [
590622
%q
@@ -791,3 +823,30 @@ resource "codefresh_pipeline" "test" {
791823
}
792824
`, rName, repo, path, revision, context, branchName, ignoreTrigger)
793825
}
826+
827+
func testAccCodefreshPipelineIsPublic(rName, repo, path, revision, context string, isPublic bool) string {
828+
return fmt.Sprintf(`
829+
resource "codefresh_pipeline" "test" {
830+
831+
lifecycle {
832+
ignore_changes = [
833+
revision
834+
]
835+
}
836+
837+
name = "%s"
838+
839+
spec {
840+
spec_template {
841+
repo = %q
842+
path = %q
843+
revision = %q
844+
context = %q
845+
}
846+
}
847+
848+
is_public = %t
849+
850+
}
851+
`, rName, repo, path, revision, context, isPublic)
852+
}

docs/resources/pipeline.md

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ resource "codefresh_pipeline" "test" {
8787

8888
- `name` - (Required) The display name for the pipeline.
8989
- `revision` - (Optional) The pipeline's revision. Should be added to the **lifecycle/ignore_changes** or incremented mannually each update.
90+
- `is_public` - (Optional) Boolean that specifies if the build logs are publicly accessible. Default: false
9091
- `tags` - (Optional) A list of tags to mark a project for easy management and access control.
9192
- `spec` - (Required) A collection of `spec` blocks as documented below.
9293
- `original_yaml_string` - (Optional) A string with original yaml pipeline.

0 commit comments

Comments
 (0)