diff --git a/go.mod b/go.mod index 1c77b752..bb7aaa43 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/hashicorp/terraform v0.12.0 github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596 github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/scalr/go-scalr v0.0.0-20210210153908-cc4b896f1392 + github.com/scalr/go-scalr v0.0.0-20210409150119-91a63924ba82 ) go 1.13 diff --git a/go.sum b/go.sum index 6c9f7aec..9f4cf3ff 100644 --- a/go.sum +++ b/go.sum @@ -315,16 +315,8 @@ github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNue github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/scalr/go-scalr v0.0.0-20201202105129-922fc963a53b h1:JIXSPuMw2wdOeTnl9SgjZYlXtQCFpdKIjtErxpgUi+4= -github.com/scalr/go-scalr v0.0.0-20201202105129-922fc963a53b/go.mod h1:eEDwNsOdDKg5TJHljpJWfb4LhobfCkUHZo/uX/rPph8= -github.com/scalr/go-scalr v0.0.0-20210119110643-9039cc40492e h1:TkyqxRvCMLhEtRl2MOp6KwDtLun9XGh6aEqErJOFv8I= -github.com/scalr/go-scalr v0.0.0-20210119110643-9039cc40492e/go.mod h1:n2HQ6QxqyTySiSFTOpAL18SjCKtP+xUskMygO0KuuQU= -github.com/scalr/go-scalr v0.0.0-20210205141334-db4e3372ed61 h1:0uDGwtHyaSe3CMKK3VjkNvfmX9mM89G1P4f5ytTO6X8= -github.com/scalr/go-scalr v0.0.0-20210205141334-db4e3372ed61/go.mod h1:n2HQ6QxqyTySiSFTOpAL18SjCKtP+xUskMygO0KuuQU= -github.com/scalr/go-scalr v0.0.0-20210210152453-7bb6d92151c1 h1:gHAzXQxf45R84FzNk/EVL9yvMiALsQF/hy881+SRkUo= -github.com/scalr/go-scalr v0.0.0-20210210152453-7bb6d92151c1/go.mod h1:n2HQ6QxqyTySiSFTOpAL18SjCKtP+xUskMygO0KuuQU= -github.com/scalr/go-scalr v0.0.0-20210210153908-cc4b896f1392 h1:5omVbEGt+45vY40jFHAxR4s+ARr/csBQfGHtxSQ1HsI= -github.com/scalr/go-scalr v0.0.0-20210210153908-cc4b896f1392/go.mod h1:n2HQ6QxqyTySiSFTOpAL18SjCKtP+xUskMygO0KuuQU= +github.com/scalr/go-scalr v0.0.0-20210409150119-91a63924ba82 h1:+0Kh6Q4S9ZIGg87P3ARTOKXj04ODKEZnd+5czs9VHJE= +github.com/scalr/go-scalr v0.0.0-20210409150119-91a63924ba82/go.mod h1:n2HQ6QxqyTySiSFTOpAL18SjCKtP+xUskMygO0KuuQU= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= diff --git a/scalr/resource_scalr_workspace.go b/scalr/resource_scalr_workspace.go index 8295d12c..55c71227 100644 --- a/scalr/resource_scalr_workspace.go +++ b/scalr/resource_scalr_workspace.go @@ -97,6 +97,13 @@ func resourceScalrWorkspace() *schema.Resource { "path": { Type: schema.TypeString, + Default: "", + Optional: true, + }, + + "trigger_prefixes": { + Type: schema.TypeList, + Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, }, }, @@ -160,10 +167,16 @@ func resourceScalrWorkspaceCreate(d *schema.ResourceData, meta interface{}) erro // Get and assert the VCS repo configuration block. if v, ok := d.GetOk("vcs_repo"); ok { vcsRepo := v.([]interface{})[0].(map[string]interface{}) + triggerPrefixes := []string{} + + for _, pref := range vcsRepo["trigger_prefixes"].([]interface{}) { + triggerPrefixes = append(triggerPrefixes, pref.(string)) + } options.VCSRepo = &scalr.VCSRepoOptions{ - Identifier: scalr.String(vcsRepo["identifier"].(string)), - Path: scalr.String(vcsRepo["path"].(string)), + Identifier: scalr.String(vcsRepo["identifier"].(string)), + Path: scalr.String(vcsRepo["path"].(string)), + TriggerPrefixes: &triggerPrefixes, } // Only set the branch if one is configured. @@ -221,8 +234,9 @@ func resourceScalrWorkspaceRead(d *schema.ResourceData, meta interface{}) error var vcsRepo []interface{} if workspace.VCSRepo != nil { vcsConfig := map[string]interface{}{ - "identifier": workspace.VCSRepo.Identifier, - "path": workspace.VCSRepo.Path, + "identifier": workspace.VCSRepo.Identifier, + "path": workspace.VCSRepo.Path, + "trigger-prefixes": workspace.VCSRepo.TriggerPrefixes, } // Get and assert the VCS repo configuration block. @@ -275,11 +289,17 @@ func resourceScalrWorkspaceUpdate(d *schema.ResourceData, meta interface{}) erro // Get and assert the VCS repo configuration block. if v, ok := d.GetOk("vcs_repo"); ok { vcsRepo := v.([]interface{})[0].(map[string]interface{}) + triggerPrefixes := make([]string, 0) + + for _, pref := range vcsRepo["trigger_prefixes"].([]interface{}) { + triggerPrefixes = append(triggerPrefixes, pref.(string)) + } options.VCSRepo = &scalr.VCSRepoOptions{ - Identifier: scalr.String(vcsRepo["identifier"].(string)), - Branch: scalr.String(vcsRepo["branch"].(string)), - Path: scalr.String(vcsRepo["path"].(string)), + Identifier: scalr.String(vcsRepo["identifier"].(string)), + Branch: scalr.String(vcsRepo["branch"].(string)), + Path: scalr.String(vcsRepo["path"].(string)), + TriggerPrefixes: &triggerPrefixes, } }