Skip to content

Commit

Permalink
SCALRCORE-28287 Workspace > Trigger Patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
DayS1eeper committed Oct 5, 2023
1 parent e3797d4 commit 41cd554
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion docs/resources/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ Optional:
- `dry_runs_enabled` (Boolean) Set (true/false) to configure the VCS driven dry runs should run when pull request to configuration versions branch created. Default `true`.
- `ingress_submodules` (Boolean) Designates whether to clone git submodules of the VCS repository.
- `path` (String, Deprecated) The repository subdirectory that Terraform will execute from. If omitted or submitted as an empty string, this defaults to the repository's root.
- `trigger_prefixes` (List of String) List of paths (relative to `path`), whose changes will trigger a run for the workspace using this binding when the CV is created. If omitted or submitted as an empty list, any change in `path` will trigger a new run.
- `trigger_patterns` (String) The gitignore-style patterns for files, whose changes will trigger a run for the workspace using this binding when the CV is created. Conflicts with `trigger_prefixes`. If `trigger_prefixes` and `trigger_patterns` are omitted, any change in `path` will trigger a new run.
- `trigger_prefixes` (List of String) List of paths (relative to `path`), whose changes will trigger a run for the workspace using this binding when the CV is created. Conflicts with `trigger_patterns`. If `trigger_prefixes` and `trigger_patterns` are omitted, any change in `path` will trigger a new run.


<a id="nestedatt--created_by"></a>
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
github.com/scalr/go-scalr v0.0.0-20230927092645-93eaae8b79df
github.com/scalr/go-scalr v0.0.0-20231004160327-c0bbb43d3b4f
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/scalr/go-scalr v0.0.0-20230927092645-93eaae8b79df h1:K8+luuthRvtvKapPOuDMqGpAchsdFVhgI3MgxwBURcg=
github.com/scalr/go-scalr v0.0.0-20230927092645-93eaae8b79df/go.mod h1:p34SHb25YRvbgft7SUjSDYESeoQhWzAlxGXId/BbaSE=
github.com/scalr/go-scalr v0.0.0-20231004160327-c0bbb43d3b4f h1:2acK1M8YNfTe1rpn9UUhR0UIGMWCmHw4BMxQCCM7lPo=
github.com/scalr/go-scalr v0.0.0-20231004160327-c0bbb43d3b4f/go.mod h1:p34SHb25YRvbgft7SUjSDYESeoQhWzAlxGXId/BbaSE=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
Expand Down
23 changes: 17 additions & 6 deletions scalr/resource_scalr_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"errors"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"log"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

Expand Down Expand Up @@ -247,11 +248,18 @@ func resourceScalrWorkspace() *schema.Resource {
},

"trigger_prefixes": {
Description: "List of paths (relative to `path`), whose changes will trigger a run for the workspace using this binding when the CV is created. If omitted or submitted as an empty list, any change in `path` will trigger a new run.",
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Computed: true,
Description: "List of paths (relative to `path`), whose changes will trigger a run for the workspace using this binding when the CV is created. Conflicts with `trigger_patterns`. If `trigger_prefixes` and `trigger_patterns` are omitted, any change in `path` will trigger a new run.",
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Computed: true,
ConflictsWith: []string{"vcs_repo.0.trigger_patterns"},
},
"trigger_patterns": {
Description: "The gitignore-style patterns for files, whose changes will trigger a run for the workspace using this binding when the CV is created. Conflicts with `trigger_prefixes`. If `trigger_prefixes` and `trigger_patterns` are omitted, any change in `path` will trigger a new run.",
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"vcs_repo.0.trigger_prefixes"},
},

"dry_runs_enabled": {
Expand Down Expand Up @@ -418,6 +426,7 @@ func resourceScalrWorkspaceCreate(ctx context.Context, d *schema.ResourceData, m
Identifier: scalr.String(vcsRepo["identifier"].(string)),
Path: scalr.String(vcsRepo["path"].(string)),
TriggerPrefixes: &triggerPrefixes,
TriggerPatterns: scalr.String(vcsRepo["trigger_patterns"].(string)),
DryRunsEnabled: scalr.Bool(vcsRepo["dry_runs_enabled"].(bool)),
IngressSubmodules: scalr.Bool(vcsRepo["ingress_submodules"].(bool)),
}
Expand Down Expand Up @@ -555,6 +564,7 @@ func resourceScalrWorkspaceRead(ctx context.Context, d *schema.ResourceData, met
"identifier": workspace.VCSRepo.Identifier,
"path": workspace.VCSRepo.Path,
"trigger_prefixes": workspace.VCSRepo.TriggerPrefixes,
"trigger_patterns": workspace.VCSRepo.TriggerPatterns,
"dry_runs_enabled": workspace.VCSRepo.DryRunsEnabled,
"ingress_submodules": workspace.VCSRepo.IngressSubmodules,
})
Expand Down Expand Up @@ -691,6 +701,7 @@ func resourceScalrWorkspaceUpdate(ctx context.Context, d *schema.ResourceData, m
Branch: scalr.String(vcsRepo["branch"].(string)),
Path: scalr.String(vcsRepo["path"].(string)),
TriggerPrefixes: &triggerPrefixes,
TriggerPatterns: scalr.String(vcsRepo["trigger_patterns"].(string)),
DryRunsEnabled: scalr.Bool(vcsRepo["dry_runs_enabled"].(bool)),
IngressSubmodules: scalr.Bool(vcsRepo["ingress_submodules"].(bool)),
}
Expand Down

0 comments on commit 41cd554

Please sign in to comment.