From b0a29b238bdd4bcd4ae3c6f8690f95165dd9eceb Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Tue, 15 Mar 2022 17:14:38 +0200 Subject: [PATCH 01/50] SCALRCORE-18405 add var-files attr to workspace resource --- docs/resources/scalr_workspace.md | 1 + go.mod | 2 +- go.sum | 2 ++ scalr/resource_scalr_workspace.go | 30 +++++++++++++++++++++++++- scalr/resource_scalr_workspace_test.go | 12 +++++++++++ 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/docs/resources/scalr_workspace.md b/docs/resources/scalr_workspace.md index bd8c0699..5205caef 100644 --- a/docs/resources/scalr_workspace.md +++ b/docs/resources/scalr_workspace.md @@ -96,6 +96,7 @@ resource "scalr_workspace" "cli-driven" { Defaults to `true`. * `terraform_version` - (Optional) The version of Terraform to use for this workspace. Defaults to the latest available version. * `working_directory` - (Optional) A relative path that Terraform will be run in. Defaults to the root of the repository `""`. +* `var_files` - (Optional) List of paths to the workspace variables files. * `module_version_id` - (Optional) The identifier of a module version in the format `modver-`. This attribute conflicts with `vcs_provider_id` and `vcs_repo` attributes. * `agent_pool_id` - (Optional) The identifier of an agent pool in the format `apool-`. * `vcs_provider_id` - (Optional) ID of vcs provider - required if vcs-repo present and vice versa, in the format `vcs-` diff --git a/go.mod b/go.mod index b4247660..681f3404 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220210091404-3cda938612d1 + github.com/scalr/go-scalr v0.0.0-20220315151045-419324345753 ) require ( diff --git a/go.sum b/go.sum index a7bc2cfc..834e53e3 100644 --- a/go.sum +++ b/go.sum @@ -301,6 +301,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/scalr/go-scalr v0.0.0-20220210091404-3cda938612d1 h1:62zWA4iQ4iupEfjvF2jzwxokqcYUi9NM9HxTFXDD27A= github.com/scalr/go-scalr v0.0.0-20220210091404-3cda938612d1/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220315151045-419324345753 h1:tDvuhVPeAturdg61Lc7aNIEgrbeQDpDZ9p50GRSb67k= +github.com/scalr/go-scalr v0.0.0-20220315151045-419324345753/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= diff --git a/scalr/resource_scalr_workspace.go b/scalr/resource_scalr_workspace.go index f16d350c..ff812342 100644 --- a/scalr/resource_scalr_workspace.go +++ b/scalr/resource_scalr_workspace.go @@ -71,6 +71,12 @@ func resourceScalrWorkspace() *schema.Resource { Default: false, }, + "var_files": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "operations": { Type: schema.TypeBool, Optional: true, @@ -207,12 +213,27 @@ func parseTriggerPrefixDefinitions(vcsRepo map[string]interface{}) ([]string, er return triggerPrefixes, nil } +func parseVarFiles(d *schema.ResourceData) ([]string, error) { + varFiles := make([]string, 0) + varFilesRequest := d.Get("var_files").([]interface{}) + + for _, varFile := range varFilesRequest { + varFiles = append(varFiles, varFile.(string)) + } + + return varFiles, nil +} + func resourceScalrWorkspaceCreate(d *schema.ResourceData, meta interface{}) error { scalrClient := meta.(*scalr.Client) // Get the name, environment_id and vcs_provider_id. name := d.Get("name").(string) environmentID := d.Get("environment_id").(string) + varfiles, err := parseVarFiles(d) + if err != nil { + return err + } // Create a new options struct. options := scalr.WorkspaceCreateOptions{ @@ -221,6 +242,7 @@ func resourceScalrWorkspaceCreate(d *schema.ResourceData, meta interface{}) erro Operations: scalr.Bool(d.Get("operations").(bool)), Environment: &scalr.Environment{ID: environmentID}, Hooks: &scalr.HooksOptions{}, + VarFiles: varfiles, } // Process all configured options. @@ -315,6 +337,7 @@ func resourceScalrWorkspaceRead(d *schema.ResourceData, meta interface{}) error d.Set("working_directory", workspace.WorkingDirectory) d.Set("environment_id", workspace.Environment.ID) d.Set("has_resources", workspace.HasResources) + d.Set("var_files", workspace.VarFiles) if workspace.VcsProvider != nil { d.Set("vcs_provider_id", workspace.VcsProvider.ID) @@ -370,17 +393,22 @@ func resourceScalrWorkspaceUpdate(d *schema.ResourceData, meta interface{}) erro scalrClient := meta.(*scalr.Client) id := d.Id() + varfiles, err := parseVarFiles(d) + if err != nil { + return err + } if d.HasChange("name") || d.HasChange("auto_apply") || d.HasChange("terraform_version") || d.HasChange("working_directory") || d.HasChange("vcs_repo") || d.HasChange("operations") || d.HasChange("vcs_provider_id") || d.HasChange("agent_pool_id") || - d.HasChange("hooks") || d.HasChange("module_version_id") { + d.HasChange("hooks") || d.HasChange("var_files") { // Create a new options struct. options := scalr.WorkspaceUpdateOptions{ Name: scalr.String(d.Get("name").(string)), AutoApply: scalr.Bool(d.Get("auto_apply").(bool)), Operations: scalr.Bool(d.Get("operations").(bool)), + VarFiles: varfiles, Hooks: &scalr.HooksOptions{ PrePlan: scalr.String(""), PostPlan: scalr.String(""), diff --git a/scalr/resource_scalr_workspace_test.go b/scalr/resource_scalr_workspace_test.go index 03f06223..3b9bc8a1 100644 --- a/scalr/resource_scalr_workspace_test.go +++ b/scalr/resource_scalr_workspace_test.go @@ -34,6 +34,10 @@ func TestAccScalrWorkspace_basic(t *testing.T) { "scalr_workspace.test", "operations", "true"), resource.TestCheckResourceAttr( "scalr_workspace.test", "working_directory", ""), + resource.TestCheckResourceAttr( + "scalr_workspace.test", "var_files.0", "test1.tfvars"), + resource.TestCheckResourceAttr( + "scalr_workspace.test", "var_files.1", "test2.tfvars"), resource.TestCheckResourceAttr( "scalr_workspace.test", "hooks.0.pre_plan", "./scripts/pre-plan.sh"), resource.TestCheckResourceAttr( @@ -159,6 +163,8 @@ func TestAccScalrWorkspace_update(t *testing.T) { resource.TestCheckResourceAttr("scalr_workspace.test", "auto_apply", "true"), resource.TestCheckResourceAttr("scalr_workspace.test", "operations", "true"), resource.TestCheckResourceAttr("scalr_workspace.test", "working_directory", ""), + resource.TestCheckResourceAttr("scalr_workspace.test", "var_files.0", "test1.tfvars"), + resource.TestCheckResourceAttr("scalr_workspace.test", "var_files.1", "test2.tfvars"), resource.TestCheckResourceAttr( "scalr_workspace.test", "hooks.0.pre_plan", "./scripts/pre-plan.sh"), resource.TestCheckResourceAttr( @@ -186,6 +192,10 @@ func TestAccScalrWorkspace_update(t *testing.T) { "scalr_workspace.test", "terraform_version", "0.12.19"), resource.TestCheckResourceAttr( "scalr_workspace.test", "working_directory", "terraform/test"), + resource.TestCheckResourceAttr( + "scalr_workspace.test", "var_files.0", "test1updated.tfvars"), + resource.TestCheckResourceAttr( + "scalr_workspace.test", "var_files.1", "test2updated.tfvars"), resource.TestCheckResourceAttr( "scalr_workspace.test", "hooks.0.pre_plan", "./scripts/pre-plan_updated.sh"), resource.TestCheckResourceAttr( @@ -420,6 +430,7 @@ resource scalr_workspace test { name = "workspace-test" environment_id = scalr_environment.test.id auto_apply = true + var_files = ["test1.tfvars", "test2.tfvars"] hooks { pre_plan = "./scripts/pre-plan.sh" post_plan = "./scripts/post-plan.sh" @@ -462,6 +473,7 @@ resource "scalr_workspace" "test" { operations = false terraform_version = "0.12.19" working_directory = "terraform/test" + var_files = ["test1updated.tfvars", "test2updated.tfvars"] hooks { pre_plan = "./scripts/pre-plan_updated.sh" post_plan = "./scripts/post-plan_updated.sh" From c2a020b5428aabd489194b0bf291f17378f6fcee Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Tue, 15 Mar 2022 17:16:12 +0200 Subject: [PATCH 02/50] SCALRCORE-18405 update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bb1ad23..8738331f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- `scalr_workspace`: added new attribute `var_files` ([#63](https://github.com/Scalr/terraform-provider-scalr/pull/118)) + ## [1.0.0-rc27] - 2022-02-17 ### Fixed From 35726e446c6b5b142899d89fdf8c0c9ea79ad75f Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Wed, 16 Mar 2022 08:31:38 +0200 Subject: [PATCH 03/50] SCALRCORE-18405 update changelog [API_BRANCH] [DB_BRANCH] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8738331f..2e256e8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed -- `scalr_workspace`: added new attribute `var_files` ([#63](https://github.com/Scalr/terraform-provider-scalr/pull/118)) +- `scalr_workspace`: added new attribute `var_files` ([#118](https://github.com/Scalr/terraform-provider-scalr/pull/118)) ## [1.0.0-rc27] - 2022-02-17 From 66c3bdeb4968f202d77f5a23a713cf324eeea46c Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Thu, 24 Mar 2022 17:23:41 +0200 Subject: [PATCH 04/50] SCALRCORE-18405 update go.mod go.sum [API_BRANCH] [DB_BRANCH] --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index f3db133e..681f3404 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220312211514-108b023567c2 + github.com/scalr/go-scalr v0.0.0-20220315151045-419324345753 ) require ( diff --git a/go.sum b/go.sum index 245e8f39..33984bec 100644 --- a/go.sum +++ b/go.sum @@ -303,6 +303,8 @@ github.com/scalr/go-scalr v0.0.0-20220312161253-be1cf5060c4d h1:iqC/j9lCiqhlYJ/s github.com/scalr/go-scalr v0.0.0-20220312161253-be1cf5060c4d/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220312211514-108b023567c2 h1:jz7JFRKlVq+IOLZKginOXZrpn2N7/NvgrY5B29wIvig= github.com/scalr/go-scalr v0.0.0-20220312211514-108b023567c2/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220315151045-419324345753 h1:tDvuhVPeAturdg61Lc7aNIEgrbeQDpDZ9p50GRSb67k= +github.com/scalr/go-scalr v0.0.0-20220315151045-419324345753/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From dd6237f495872564eac674d132ba7b9b5f7d5e14 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Fri, 25 Mar 2022 11:10:05 +0200 Subject: [PATCH 05/50] SCALRCORE-18405 update go.mod go.sum [API_BRANCH] [DB_BRANCH] --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 681f3404..c868756c 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220315151045-419324345753 + github.com/scalr/go-scalr v0.0.0-20220324152224-fe1a0465afc8 ) require ( diff --git a/go.sum b/go.sum index 33984bec..cf761f57 100644 --- a/go.sum +++ b/go.sum @@ -305,6 +305,8 @@ github.com/scalr/go-scalr v0.0.0-20220312211514-108b023567c2 h1:jz7JFRKlVq+IOLZK github.com/scalr/go-scalr v0.0.0-20220312211514-108b023567c2/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220315151045-419324345753 h1:tDvuhVPeAturdg61Lc7aNIEgrbeQDpDZ9p50GRSb67k= github.com/scalr/go-scalr v0.0.0-20220315151045-419324345753/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220324152224-fe1a0465afc8 h1:pmUMCNj/acCztQVyroieMpC1+Mn2wxBWe4DBP5ZnZMQ= +github.com/scalr/go-scalr v0.0.0-20220324152224-fe1a0465afc8/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From 5cce684d2e6187217f76ea689cd8c21423f3bb8e Mon Sep 17 00:00:00 2001 From: soltysss Date: Tue, 29 Mar 2022 22:16:18 +0300 Subject: [PATCH 06/50] SCALRCORE-20543 - API > link environment to policy group optimization --- CHANGELOG.md | 1 + go.mod | 2 +- go.sum | 2 ++ scalr/resource_scalr_policy_group_linkage.go | 28 +++++--------------- 4 files changed, 10 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db7e5a28..e99021bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - `resource.scalr_role`: added new state migration (include `accounts:set-quotas` permission if needed) ([#116](https://github.com/Scalr/terraform-provider-scalr/pull/108)) +- `resource.scalr_policy_group_linkage`: optimized api interactions ### Fixed diff --git a/go.mod b/go.mod index 9849356d..cdf144d9 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220325112237-ed0177c822fe + github.com/scalr/go-scalr v0.0.0-20220329174802-9feced1a221f ) require ( diff --git a/go.sum b/go.sum index 0f5deed8..11a927db 100644 --- a/go.sum +++ b/go.sum @@ -301,6 +301,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/scalr/go-scalr v0.0.0-20220325112237-ed0177c822fe h1:ByXm55tBvaFoLqUcwXd3O3VkpRG4BP2RYdtVyL/NUBw= github.com/scalr/go-scalr v0.0.0-20220325112237-ed0177c822fe/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220329174802-9feced1a221f h1:MRLfsni0ewK3BlNQejbZTSe1n74NjRX6zcyR6emoZt8= +github.com/scalr/go-scalr v0.0.0-20220329174802-9feced1a221f/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= diff --git a/scalr/resource_scalr_policy_group_linkage.go b/scalr/resource_scalr_policy_group_linkage.go index 5cded9f7..51c4aac3 100644 --- a/scalr/resource_scalr_policy_group_linkage.go +++ b/scalr/resource_scalr_policy_group_linkage.go @@ -60,19 +60,11 @@ func resourceScalrPolicyGroupLinkageCreate(d *schema.ResourceData, meta interfac envID := d.Get("environment_id").(string) id := packPolicyGroupLinkageID(pgID, envID) - environment, err := scalrClient.Environments.Read(ctx, envID) - if err != nil { - if errors.Is(err, scalr.ErrResourceNotFound) { - return fmt.Errorf("environment %s not found", envID) - } - return fmt.Errorf("error creating policy group linkage %s: %v", id, err) + opts := scalr.PolicyGroupEnvironmentsCreateOptions{ + PolicyGroupID: pgID, + PolicyGroupEnvironments: []*scalr.PolicyGroupEnvironment{{ID: envID}}, } - - // existing policy groups of the environment plus the new one - policyGroups := append(environment.PolicyGroups, &scalr.PolicyGroup{ID: pgID}) - - opts := scalr.EnvironmentUpdateOptions{PolicyGroups: policyGroups} - _, err = scalrClient.Environments.Update(ctx, envID, opts) + err = scalrClient.PolicyGroupEnvironments.Create(ctx, opts) if err != nil { return fmt.Errorf("error creating policy group linkage %s: %v", id, err) } @@ -116,16 +108,8 @@ func resourceScalrPolicyGroupLinkageDelete(d *schema.ResourceData, meta interfac return fmt.Errorf("error deleting policy group linkage %s: %v", id, err) } - // existing policy groups of the environment that will remain linked - var policyGroups []*scalr.PolicyGroup - for _, pg := range environment.PolicyGroups { - if pg.ID != policyGroup.ID { - policyGroups = append(policyGroups, pg) - } - } - - opts := scalr.EnvironmentUpdateOptions{PolicyGroups: policyGroups} - _, err = scalrClient.Environments.Update(ctx, environment.ID, opts) + opts := scalr.PolicyGroupEnvironmentDeleteOptions{PolicyGroupID: policyGroup.ID, EnvironmentID: environment.ID} + err = scalrClient.PolicyGroupEnvironments.Delete(ctx, opts) if err != nil { return fmt.Errorf("error deleting policy group linkage %s: %v", id, err) } From 4c30ef6e5343602ae6c99b55bb0743b74a7e763c Mon Sep 17 00:00:00 2001 From: soltysss Date: Tue, 29 Mar 2022 22:20:44 +0300 Subject: [PATCH 07/50] SCALRCORE-20543 - API > link environment to policy group optimization --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e99021bb..4668a073 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,11 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - `resource.scalr_role`: added new state migration (include `accounts:set-quotas` permission if needed) ([#116](https://github.com/Scalr/terraform-provider-scalr/pull/108)) -- `resource.scalr_policy_group_linkage`: optimized api interactions ### Fixed - Correctly handle not found resources ([#117](https://github.com/Scalr/terraform-provider-scalr/pull/117)) +- `resource.scalr_policy_group_linkage`: optimized api interactions ([#120](https://github.com/Scalr/terraform-provider-scalr/pull/120)) ## [1.0.0-rc27] - 2022-02-17 From 765190ff9c30336dc8b1ec69424d12894c67a72e Mon Sep 17 00:00:00 2001 From: soltysss Date: Tue, 29 Mar 2022 22:29:26 +0300 Subject: [PATCH 08/50] SCALRCORE-20543 - API > link environment to policy group optimization [API_BRANCH] --- scalr/resource_scalr_policy_group_linkage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scalr/resource_scalr_policy_group_linkage.go b/scalr/resource_scalr_policy_group_linkage.go index 51c4aac3..8f06645b 100644 --- a/scalr/resource_scalr_policy_group_linkage.go +++ b/scalr/resource_scalr_policy_group_linkage.go @@ -64,7 +64,7 @@ func resourceScalrPolicyGroupLinkageCreate(d *schema.ResourceData, meta interfac PolicyGroupID: pgID, PolicyGroupEnvironments: []*scalr.PolicyGroupEnvironment{{ID: envID}}, } - err = scalrClient.PolicyGroupEnvironments.Create(ctx, opts) + err := scalrClient.PolicyGroupEnvironments.Create(ctx, opts) if err != nil { return fmt.Errorf("error creating policy group linkage %s: %v", id, err) } From 888b6cd749ea1a61aba44706e62ee531a33e3edc Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Fri, 1 Apr 2022 10:45:58 +0300 Subject: [PATCH 09/50] SCALRCORE-18405 update go.mod go.sum --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2f0e3702..67577c5e 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661 + github.com/scalr/go-scalr v0.0.0-20220401073935-00716023b60d ) require ( diff --git a/go.sum b/go.sum index 468d653e..1b08b227 100644 --- a/go.sum +++ b/go.sum @@ -301,6 +301,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661 h1:DnvLMEoIGdre8txCto7ml8mvI/LcIA+uqtdhXRDUY3o= github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220401073935-00716023b60d h1:PuAp5ybcXOJIZx7mAonbK93KIYb831PD6y8/yq8Xwbs= +github.com/scalr/go-scalr v0.0.0-20220401073935-00716023b60d/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From 242fdbc4ca7b65f3b9a37281469e6c34fc4411b3 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Fri, 1 Apr 2022 11:12:22 +0300 Subject: [PATCH 10/50] SCALRCORE-18405 update changelog [API_BRANCH] [DB_BRANCH] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b09bc081..38ece6f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `scalr_workspace`: added new attribute `run_operation_timeout` ### Changed -- `scalr_workspace`: added new attribute `var_files` ([#118](https://github.com/Scalr/terraform-provider-scalr/pull/118)) +- `scalr_workspace`: added new attribute `var_files` ([#118](https://github.com/Scalr/terraform-provider-scalr/pull/118)) - `resource.scalr_role`: added new state migration (include `accounts:set-quotas` permission if needed) ([#116](https://github.com/Scalr/terraform-provider-scalr/pull/108)) ### Fixed From f4e1ddcb5ef932ca4edb49476b320ff3cd1a7732 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Fri, 1 Apr 2022 16:05:01 +0300 Subject: [PATCH 11/50] SCALRCORE-18405 CR fixes --- scalr/resource_scalr_workspace.go | 40 ++++++++++++++----------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/scalr/resource_scalr_workspace.go b/scalr/resource_scalr_workspace.go index 97da7aa0..73892151 100644 --- a/scalr/resource_scalr_workspace.go +++ b/scalr/resource_scalr_workspace.go @@ -217,27 +217,12 @@ func parseTriggerPrefixDefinitions(vcsRepo map[string]interface{}) ([]string, er return triggerPrefixes, nil } -func parseVarFiles(d *schema.ResourceData) ([]string, error) { - varFiles := make([]string, 0) - varFilesRequest := d.Get("var_files").([]interface{}) - - for _, varFile := range varFilesRequest { - varFiles = append(varFiles, varFile.(string)) - } - - return varFiles, nil -} - func resourceScalrWorkspaceCreate(d *schema.ResourceData, meta interface{}) error { scalrClient := meta.(*scalr.Client) // Get the name, environment_id and vcs_provider_id. name := d.Get("name").(string) environmentID := d.Get("environment_id").(string) - varfiles, err := parseVarFiles(d) - if err != nil { - return err - } // Create a new options struct. options := scalr.WorkspaceCreateOptions{ @@ -246,7 +231,6 @@ func resourceScalrWorkspaceCreate(d *schema.ResourceData, meta interface{}) erro Operations: scalr.Bool(d.Get("operations").(bool)), Environment: &scalr.Environment{ID: environmentID}, Hooks: &scalr.HooksOptions{}, - VarFiles: varfiles, } // Process all configured options. @@ -313,6 +297,14 @@ func resourceScalrWorkspaceCreate(d *schema.ResourceData, meta interface{}) erro } } + if v, ok := d.Get("var_files").([]interface{}); ok { + varFiles := make([]string, 0) + for _, varFile := range v { + varFiles = append(varFiles, varFile.(string)) + } + options.VarFiles = varFiles + } + log.Printf("[DEBUG] Create workspace %s for environment: %s", name, environmentID) workspace, err := scalrClient.Workspaces.Create(ctx, options) if err != nil { @@ -405,22 +397,18 @@ func resourceScalrWorkspaceUpdate(d *schema.ResourceData, meta interface{}) erro scalrClient := meta.(*scalr.Client) id := d.Id() - varfiles, err := parseVarFiles(d) - if err != nil { - return err - } if d.HasChange("name") || d.HasChange("auto_apply") || d.HasChange("terraform_version") || d.HasChange("working_directory") || d.HasChange("vcs_repo") || d.HasChange("operations") || d.HasChange("vcs_provider_id") || d.HasChange("agent_pool_id") || - d.HasChange("hooks") || d.HasChange("var_files") || d.HasChange("run_operation_timeout") { + d.HasChange("hooks") || d.HasChange("module_version_id") || d.HasChange("var_files") || + d.HasChange("run_operation_timeout") { // Create a new options struct. options := scalr.WorkspaceUpdateOptions{ Name: scalr.String(d.Get("name").(string)), AutoApply: scalr.Bool(d.Get("auto_apply").(bool)), Operations: scalr.Bool(d.Get("operations").(bool)), - VarFiles: varfiles, Hooks: &scalr.HooksOptions{ PrePlan: scalr.String(""), PostPlan: scalr.String(""), @@ -434,6 +422,14 @@ func resourceScalrWorkspaceUpdate(d *schema.ResourceData, meta interface{}) erro options.TerraformVersion = scalr.String(tfVersion.(string)) } + if v, ok := d.Get("var_files").([]interface{}); ok { + varFiles := make([]string, 0) + for _, varFile := range v { + varFiles = append(varFiles, varFile.(string)) + } + options.VarFiles = varFiles + } + options.WorkingDirectory = scalr.String(d.Get("working_directory").(string)) if runOperationTimeout, ok := d.GetOk("run_operation_timeout"); ok { From 7e1cb98220dc5f3689038737a7968954df5b0e91 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Fri, 1 Apr 2022 16:14:14 +0300 Subject: [PATCH 12/50] SCALRCORE-18405 CR fixes [API_BRANCH] [DB_BRANCH] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38ece6f4..b09bc081 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `scalr_workspace`: added new attribute `run_operation_timeout` ### Changed -- `scalr_workspace`: added new attribute `var_files` ([#118](https://github.com/Scalr/terraform-provider-scalr/pull/118)) +- `scalr_workspace`: added new attribute `var_files` ([#118](https://github.com/Scalr/terraform-provider-scalr/pull/118)) - `resource.scalr_role`: added new state migration (include `accounts:set-quotas` permission if needed) ([#116](https://github.com/Scalr/terraform-provider-scalr/pull/108)) ### Fixed From bdc273903eef5a38ed0757b6fc6a290882901cc5 Mon Sep 17 00:00:00 2001 From: soltysss Date: Mon, 11 Apr 2022 01:35:15 +0300 Subject: [PATCH 13/50] SCALRCORE-21039 - Scalr Provider > Add support for Run Scheduler [API_BRANCH] --- .../resources/scalr_workspace_run_schedule.md | 37 +++++ go.mod | 2 +- go.sum | 6 + scalr/client_mock.go | 4 + scalr/provider.go | 33 ++-- .../resource_scalr_workspace_run_schedule.go | 144 ++++++++++++++++++ ...ource_scalr_workspace_run_schedule_test.go | 86 +++++++++++ 7 files changed, 295 insertions(+), 17 deletions(-) create mode 100644 docs/resources/scalr_workspace_run_schedule.md create mode 100644 scalr/resource_scalr_workspace_run_schedule.go create mode 100644 scalr/resource_scalr_workspace_run_schedule_test.go diff --git a/docs/resources/scalr_workspace_run_schedule.md b/docs/resources/scalr_workspace_run_schedule.md new file mode 100644 index 00000000..2ad21ae0 --- /dev/null +++ b/docs/resources/scalr_workspace_run_schedule.md @@ -0,0 +1,37 @@ +--- +layout: "scalr" +page_title: "Scalr: scalr_workspace_run_schedule" +sidebar_current: "docs-resource-scalr-workspace-run-schedule" +description: |- +Manages run schedules. +--- + +# scalr_workspace_run_schedule Resource + +Manage the state of workspace run schedules in Scalr. Create, update and destroy + +## Example Usage + +Basic usage: + +```hcl +resource "scalr_workspace_run_schedule" "example" { + workspace_id = "ws-xxxxxx" + apply_schedule = "30 3 5 3-5 2" + destroy_schedule = "30 4 5 3-5 2" +} +``` + +## Argument Reference + +* `workspace_id` - (Required) ID of the workspace, in the format `ws-`. +* `apply_schedule` - (Optional) Cron expression for when apply run should be created. +* `destroy_schedule` - (Optional) Cron expression for when destroy run should be created. + + +## Attribute Reference + +All arguments plus: + +* `id` - The workspaces's ID, in the format `ws-`. + diff --git a/go.mod b/go.mod index 2f0e3702..0c303f3a 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661 + github.com/scalr/go-scalr v0.0.0-20220410204153-c2c68c922f50 ) require ( diff --git a/go.sum b/go.sum index 468d653e..49b0953c 100644 --- a/go.sum +++ b/go.sum @@ -301,6 +301,12 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661 h1:DnvLMEoIGdre8txCto7ml8mvI/LcIA+uqtdhXRDUY3o= github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220408002318-75c4f82e53dc h1:uu79KW7K7rFG/zNHztct42dsHsa1XV6EIGOsIbKyXa0= +github.com/scalr/go-scalr v0.0.0-20220408002318-75c4f82e53dc/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220410193218-92674cb5154f h1:7kYe9z1cJgDPlrjg+iBkLVMS0WKLF2TqCemzTH0qzkI= +github.com/scalr/go-scalr v0.0.0-20220410193218-92674cb5154f/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220410204153-c2c68c922f50 h1:wpvLzc/lY1N8eEz2228hjdogPQlCwvbeD7e9TLI1GVw= +github.com/scalr/go-scalr v0.0.0-20220410204153-c2c68c922f50/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= diff --git a/scalr/client_mock.go b/scalr/client_mock.go index cb992dde..acc32a11 100644 --- a/scalr/client_mock.go +++ b/scalr/client_mock.go @@ -89,6 +89,10 @@ func (m *mockWorkspaces) Delete(ctx context.Context, workspaceID string) error { panic("not implemented") } +func (m *mockWorkspaces) SetSchedule(ctx context.Context, workspaceID string, options scalr.WorkspaceRunScheduleOptions) (*scalr.Workspace, error) { + panic("not implemented") +} + func (m *mockVariables) Update(ctx context.Context, variableID string, options scalr.VariableUpdateOptions) (*scalr.Variable, error) { panic("not implemented") } diff --git a/scalr/provider.go b/scalr/provider.go index 3279c108..944a9f66 100644 --- a/scalr/provider.go +++ b/scalr/provider.go @@ -80,22 +80,23 @@ func Provider() terraform.ResourceProvider { }, ResourcesMap: map[string]*schema.Resource{ - "scalr_access_policy": resourceScalrAccessPolicy(), - "scalr_account_allowed_ips": resourceScalrAccountAllowedIps(), - "scalr_agent_pool": resourceScalrAgentPool(), - "scalr_agent_pool_token": resourceScalrAgentPoolToken(), - "scalr_endpoint": resourceScalrEndpoint(), - "scalr_environment": resourceScalrEnvironment(), - "scalr_iam_team": resourceScalrIamTeam(), - "scalr_module": resourceScalrModule(), - "scalr_policy_group": resourceScalrPolicyGroup(), - "scalr_policy_group_linkage": resourceScalrPolicyGroupLinkage(), - "scalr_role": resourceScalrRole(), - "scalr_variable": resourceScalrVariable(), - "scalr_vcs_provider": resourceScalrVcsProvider(), - "scalr_webhook": resourceScalrWebhook(), - "scalr_workspace": resourceScalrWorkspace(), - "scalr_run_trigger": resourceScalrRunTrigger(), + "scalr_access_policy": resourceScalrAccessPolicy(), + "scalr_account_allowed_ips": resourceScalrAccountAllowedIps(), + "scalr_agent_pool": resourceScalrAgentPool(), + "scalr_agent_pool_token": resourceScalrAgentPoolToken(), + "scalr_endpoint": resourceScalrEndpoint(), + "scalr_environment": resourceScalrEnvironment(), + "scalr_iam_team": resourceScalrIamTeam(), + "scalr_module": resourceScalrModule(), + "scalr_policy_group": resourceScalrPolicyGroup(), + "scalr_policy_group_linkage": resourceScalrPolicyGroupLinkage(), + "scalr_role": resourceScalrRole(), + "scalr_variable": resourceScalrVariable(), + "scalr_vcs_provider": resourceScalrVcsProvider(), + "scalr_webhook": resourceScalrWebhook(), + "scalr_workspace": resourceScalrWorkspace(), + "scalr_run_trigger": resourceScalrRunTrigger(), + "scalr_workspace_run_schedule": resourceScalrWorkspaceRunSchedule(), }, ConfigureFunc: providerConfigure, diff --git a/scalr/resource_scalr_workspace_run_schedule.go b/scalr/resource_scalr_workspace_run_schedule.go new file mode 100644 index 00000000..fd72865b --- /dev/null +++ b/scalr/resource_scalr_workspace_run_schedule.go @@ -0,0 +1,144 @@ +package scalr + +import ( + "errors" + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/scalr/go-scalr" + "log" +) + +func resourceScalrWorkspaceRunSchedule() *schema.Resource { + return &schema.Resource{ + Create: resourceScalrWorkspaceRunScheduleCreate, + Read: resourceScalrWorkspaceRunScheduleRead, + Update: resourceScalrWorkspaceRunScheduleUpdate, + Delete: resourceScalrWorkspaceRunScheduleDelete, + Importer: &schema.ResourceImporter{ + State: resourceScalrWorkspaceRunScheduleImport, + }, + + Schema: map[string]*schema.Schema{ + "workspace_id": { + Type: schema.TypeString, + Required: true, + }, + "apply_schedule": { + Type: schema.TypeString, + Optional: true, + Default: "", + }, + "destroy_schedule": { + Type: schema.TypeString, + Optional: true, + Default: "", + }, + }, + } +} + +func resourceScalrWorkspaceRunScheduleCreate(d *schema.ResourceData, meta interface{}) error { + scalrClient := meta.(*scalr.Client) + + workspaceId := d.Get("workspace_id").(string) + + // Create a new options struct. + options := scalr.WorkspaceRunScheduleOptions{} + + options.ApplySchedule = d.Get("apply_schedule").(string) + options.DestroySchedule = d.Get("destroy_schedule").(string) + + log.Printf( + "[DEBUG] Setting run schdules for workspace ID: %s, apply: %s, destroy: %s", + workspaceId, + options.ApplySchedule, + options.DestroySchedule, + ) + workspace, err := scalrClient.Workspaces.SetSchedule(ctx, workspaceId, options) + if err != nil { + return fmt.Errorf("Error setting run schedule for workspace %s: %v", workspaceId, err) + } + + d.SetId(workspace.ID) + + return resourceScalrWorkspaceRunScheduleRead(d, meta) +} + +func resourceScalrWorkspaceRunScheduleRead(d *schema.ResourceData, meta interface{}) error { + scalrClient := meta.(*scalr.Client) + workspaceId := d.Id() + + log.Printf("[DEBUG] Read Workspace with ID: %s", workspaceId) + workspace, err := scalrClient.Workspaces.ReadByID(ctx, workspaceId) + if err != nil { + if errors.Is(err, scalr.ErrResourceNotFound) { + d.SetId("") + return nil + } + return fmt.Errorf("Error retrieving workspace: %v", err) + } + + // Update the config. + d.Set("apply_schedule", workspace.ApplySchedule) + d.Set("destroy_schedule", workspace.DestroySchedule) + + d.SetId(workspace.ID) + + return nil +} + +func resourceScalrWorkspaceRunScheduleUpdate(d *schema.ResourceData, meta interface{}) error { + scalrClient := meta.(*scalr.Client) + + var err error + workspaceId := d.Id() + + if d.HasChange("apply_schedule") || d.HasChange("destroy_schedule") { + // Create a new options struct. + options := scalr.WorkspaceRunScheduleOptions{} + + options.ApplySchedule = d.Get("apply_schedule").(string) + options.DestroySchedule = d.Get("destroy_schedule").(string) + + log.Printf( + "[DEBUG] Setting run schdules for workspace ID: %s, apply: %s, destroy: %s", + workspaceId, + options.ApplySchedule, + options.DestroySchedule, + ) + _, err = scalrClient.Workspaces.SetSchedule(ctx, workspaceId, options) + if err != nil { + return fmt.Errorf("Error setting run schedule for workspace %s: %v", workspaceId, err) + } + } + + return resourceScalrWorkspaceRunScheduleRead(d, meta) +} + +func resourceScalrWorkspaceRunScheduleDelete(d *schema.ResourceData, meta interface{}) error { + scalrClient := meta.(*scalr.Client) + + log.Printf("[DEBUG] Delete run schedules for workspace: %s", d.Id()) + _, err := scalrClient.Workspaces.SetSchedule(ctx, d.Id(), scalr.WorkspaceRunScheduleOptions{ + ApplySchedule: "", + DestroySchedule: "", + }) + if err != nil { + if errors.Is(err, scalr.ErrResourceNotFound) { + return nil + } + return fmt.Errorf("Error deleting workspace run schedules %s: %v", d.Id(), err) + } + + return nil +} + +func resourceScalrWorkspaceRunScheduleImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + err := resourceScalrWorkspaceRunScheduleRead(d, meta) + + if err != nil { + return nil, fmt.Errorf("error retrieving workspace run schedule %s: %v", d.Id(), err) + } + + return []*schema.ResourceData{d}, nil +} diff --git a/scalr/resource_scalr_workspace_run_schedule_test.go b/scalr/resource_scalr_workspace_run_schedule_test.go new file mode 100644 index 00000000..827e389b --- /dev/null +++ b/scalr/resource_scalr_workspace_run_schedule_test.go @@ -0,0 +1,86 @@ +package scalr + +import ( + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "testing" +) + +func TestScalrWorkspaceRunSchedule_basic(t *testing.T) { + rInt := GetRandomInteger() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckScalrWorkspaceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccScalrWorkspaceRunSchedule(rInt), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "scalr_workspace_run_schedule.test", "apply_schedule", "30 3 5 3-5 2"), + resource.TestCheckResourceAttr( + "scalr_workspace_run_schedule.test", "destroy_schedule", "30 4 5 3-5 2"), + ), + }, + }, + }) +} + +func TestScalrWorkspaceRunSchedule_default(t *testing.T) { + rInt := GetRandomInteger() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckScalrWorkspaceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccScalrWorkspaceRunScheduleDefaultValue(rInt), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "scalr_workspace_run_schedule.test", "apply_schedule", "0 22 * * 1-5"), + resource.TestCheckResourceAttr( + "scalr_workspace_run_schedule.test", "destroy_schedule", ""), + ), + }, + }, + }) +} + +const testScalrWorkspaceRunScheduleCommonConfig = ` +resource scalr_environment test { + name = "test-env-rs-%d" + account_id = "%s" +} +resource scalr_workspace test { + name = "workspace-run-schedule-test" + environment_id = scalr_environment.test.id + auto_apply = true + run_operation_timeout = 18 + hooks { + pre_plan = "./scripts/pre-plan.sh" + post_plan = "./scripts/post-plan.sh" + pre_apply = "./scripts/pre-apply.sh" + post_apply = "./scripts/post-apply.sh" + } +} +%s +` + +func testAccScalrWorkspaceRunSchedule(rInt int) string { + return fmt.Sprintf(testScalrWorkspaceRunScheduleCommonConfig, rInt, defaultAccount, ` +resource scalr_workspace_run_schedule test { + workspace_id = scalr_workspace.test.id + apply_schedule = "30 3 5 3-5 2" + destroy_schedule = "30 4 5 3-5 2" +}`) +} + +func testAccScalrWorkspaceRunScheduleDefaultValue(rInt int) string { + return fmt.Sprintf(testScalrWorkspaceRunScheduleCommonConfig, rInt, defaultAccount, ` +resource scalr_workspace_run_schedule test { + workspace_id = scalr_workspace.test.id + apply_schedule = "0 22 * * 1-5" +}`) +} From 5611f1d36af3b02aa4a06c9e01f4a59ed79b73ee Mon Sep 17 00:00:00 2001 From: soltysss Date: Mon, 11 Apr 2022 01:37:51 +0300 Subject: [PATCH 14/50] SCALRCORE-21039 - Scalr Provider > Add support for Run Scheduler [API_BRANCH] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e398af53..3d8081f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- **New resource:** `scalr_workspace_run_schedule` ([#124](https://github.com/Scalr/terraform-provider-scalr/pull/124)) - **New resource:** `scalr_account_allowed_ips` ([#111](https://github.com/Scalr/terraform-provider-scalr/pull/111)) - `scalr_workspace`: added a new attribute `run_operation_timeout` ([#115](https://github.com/Scalr/terraform-provider-scalr/pull/115)) From f10bb4ba5ba55862c5b980bd8638d20f44ba7461 Mon Sep 17 00:00:00 2001 From: soltysss Date: Tue, 12 Apr 2022 14:04:05 +0300 Subject: [PATCH 15/50] SCALRCORE-21039 - Scalr Provider > Add support for Run Scheduler [API_BRANCH] --- go.mod | 2 +- go.sum | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index cdf144d9..e81db075 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220329174802-9feced1a221f + github.com/scalr/go-scalr v0.0.0-20220412110021-d3ccafeed07b ) require ( diff --git a/go.sum b/go.sum index 11a927db..1630dba2 100644 --- a/go.sum +++ b/go.sum @@ -303,6 +303,10 @@ github.com/scalr/go-scalr v0.0.0-20220325112237-ed0177c822fe h1:ByXm55tBvaFoLqUc github.com/scalr/go-scalr v0.0.0-20220325112237-ed0177c822fe/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220329174802-9feced1a221f h1:MRLfsni0ewK3BlNQejbZTSe1n74NjRX6zcyR6emoZt8= github.com/scalr/go-scalr v0.0.0-20220329174802-9feced1a221f/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220412082152-93dc92abec95 h1:DC8OanW3wpdcmMMISPXxKEQqxa3gVWt8lK8rdCfi0kE= +github.com/scalr/go-scalr v0.0.0-20220412082152-93dc92abec95/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220412110021-d3ccafeed07b h1:AHNoQyfTvTbfA49v/FP7Y7WrltHXoQmUyomIfIqWpPY= +github.com/scalr/go-scalr v0.0.0-20220412110021-d3ccafeed07b/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From 1584b2056b87aced77963caa883fcacdc01aa77c Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Wed, 13 Apr 2022 16:28:02 +0300 Subject: [PATCH 16/50] SCALRCORE-18405 update changelog [API_BRANCH] [DB_BRANCH] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a6cfce0..9fe22f27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- **New resource:** `scalr_account_allowed_ips` ([#111](https://github.com/Scalr/terraform-provider-scalr/pull/111)) +- **New resource:** `scalr_account_allowed_ips` ([#111](https://github.com/Scalr/terraform-provider-scalr/pull/111)) - `scalr_workspace`: added a new attribute `run_operation_timeout` ([#115](https://github.com/Scalr/terraform-provider-scalr/pull/115)) ### Changed From 6d4a53fcc405c8e4fce00142159f10ec0654d8a4 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Wed, 13 Apr 2022 16:29:16 +0300 Subject: [PATCH 17/50] SCALRCORE-18405 update changelog [API_BRANCH] [DB_BRANCH] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fe22f27..3a6cfce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- **New resource:** `scalr_account_allowed_ips` ([#111](https://github.com/Scalr/terraform-provider-scalr/pull/111)) +- **New resource:** `scalr_account_allowed_ips` ([#111](https://github.com/Scalr/terraform-provider-scalr/pull/111)) - `scalr_workspace`: added a new attribute `run_operation_timeout` ([#115](https://github.com/Scalr/terraform-provider-scalr/pull/115)) ### Changed From e3b028dd454f8681a4c43700a735055cc1d0c5e1 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Wed, 13 Apr 2022 17:06:01 +0300 Subject: [PATCH 18/50] SCALRCORE-18405 update go.mod and go.sum [API_BRANCH] [DB_BRANCH] --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 67577c5e..73692a9d 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220401073935-00716023b60d + github.com/scalr/go-scalr v0.0.0-20220413135958-ff97860ba246 ) require ( diff --git a/go.sum b/go.sum index 1b08b227..16737690 100644 --- a/go.sum +++ b/go.sum @@ -303,6 +303,8 @@ github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661 h1:DnvLMEoIGdre8txC github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220401073935-00716023b60d h1:PuAp5ybcXOJIZx7mAonbK93KIYb831PD6y8/yq8Xwbs= github.com/scalr/go-scalr v0.0.0-20220401073935-00716023b60d/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220413135958-ff97860ba246 h1:PLwTfDPtniv8vVXC/0nAo3+Iunq5wB7stnW8Sefy5+I= +github.com/scalr/go-scalr v0.0.0-20220413135958-ff97860ba246/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From 0bcec75d20c598bd55c63d3eaf4deb85e7ba0a25 Mon Sep 17 00:00:00 2001 From: soltysss Date: Fri, 29 Apr 2022 13:43:26 +0300 Subject: [PATCH 19/50] SCALRCORE-21039 - Scalr Provider > Add support for Run Scheduler [API_BRANCH] --- scalr/resource_scalr_workspace_run_schedule.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scalr/resource_scalr_workspace_run_schedule.go b/scalr/resource_scalr_workspace_run_schedule.go index fd72865b..500b6749 100644 --- a/scalr/resource_scalr_workspace_run_schedule.go +++ b/scalr/resource_scalr_workspace_run_schedule.go @@ -49,7 +49,7 @@ func resourceScalrWorkspaceRunScheduleCreate(d *schema.ResourceData, meta interf options.DestroySchedule = d.Get("destroy_schedule").(string) log.Printf( - "[DEBUG] Setting run schdules for workspace ID: %s, apply: %s, destroy: %s", + "[DEBUG] Setting run schedules for workspace ID: %s, apply: %s, destroy: %s", workspaceId, options.ApplySchedule, options.DestroySchedule, From 4b13eb9e6d228a2767a1e8fc48c8ba30534e1f4e Mon Sep 17 00:00:00 2001 From: soltysss Date: Fri, 29 Apr 2022 16:47:27 +0300 Subject: [PATCH 20/50] SCALRCORE-21039 - Scalr Provider > Add support for Run Scheduler [API_BRANCH] --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1b140419..89a23362 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106 + github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a ) require ( diff --git a/go.sum b/go.sum index 17e7c2b1..8f826e9a 100644 --- a/go.sum +++ b/go.sum @@ -303,6 +303,8 @@ github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661 h1:DnvLMEoIGdre8txC github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106 h1:2eJf0QIg5LpWqRVULkePfcvofFKid+pcHVDyhf6Jnfw= github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a h1:P4ANn4rx4tmVLUIIm5V0hUkR0eTUImyhtla8SE1EVhc= +github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From c2c52a0a7691a0054a179726326cab094de8c904 Mon Sep 17 00:00:00 2001 From: soltysss Date: Mon, 2 May 2022 14:09:47 +0300 Subject: [PATCH 21/50] SCALRCORE-21039 - Scalr Provider > Add support for Run Scheduler [API_BRANCH] --- scalr/resource_scalr_workspace_run_schedule.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scalr/resource_scalr_workspace_run_schedule.go b/scalr/resource_scalr_workspace_run_schedule.go index 500b6749..ad035b8d 100644 --- a/scalr/resource_scalr_workspace_run_schedule.go +++ b/scalr/resource_scalr_workspace_run_schedule.go @@ -101,7 +101,7 @@ func resourceScalrWorkspaceRunScheduleUpdate(d *schema.ResourceData, meta interf options.DestroySchedule = d.Get("destroy_schedule").(string) log.Printf( - "[DEBUG] Setting run schdules for workspace ID: %s, apply: %s, destroy: %s", + "[DEBUG] Setting run schedules for workspace ID: %s, apply: %s, destroy: %s", workspaceId, options.ApplySchedule, options.DestroySchedule, From b5ed1d02bf5aad8a922e2a91b48fee8e3dd473ec Mon Sep 17 00:00:00 2001 From: soltysss Date: Fri, 6 May 2022 15:22:34 +0300 Subject: [PATCH 22/50] SCALRCORE-20543 - API > link environment to policy group optimization [API_BRANCH] --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1b140419..89caedae 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106 + github.com/scalr/go-scalr v0.0.0-20220506112707-49f02107d87e ) require ( diff --git a/go.sum b/go.sum index 17e7c2b1..cecdfdda 100644 --- a/go.sum +++ b/go.sum @@ -303,6 +303,8 @@ github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661 h1:DnvLMEoIGdre8txC github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106 h1:2eJf0QIg5LpWqRVULkePfcvofFKid+pcHVDyhf6Jnfw= github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220506112707-49f02107d87e h1:5ZiAqi2rN1/0qCc7zRzsEY4ZtZteDcpkbqXiiRecRr4= +github.com/scalr/go-scalr v0.0.0-20220506112707-49f02107d87e/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From 1b5ce09f9ec4fe8f57becf9c78349167b6113fc6 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Tue, 10 May 2022 11:46:34 +0300 Subject: [PATCH 23/50] SCALRCORE-18405 update go.mod and go.sum --- go.mod | 2 +- go.sum | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1b140419..15983b5b 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106 + github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe ) require ( diff --git a/go.sum b/go.sum index 17e7c2b1..a609f95d 100644 --- a/go.sum +++ b/go.sum @@ -299,10 +299,16 @@ github.com/posener/complete v1.2.1 h1:LrvDIY//XNo65Lq84G/akBuMGlawHvGBABv8f/ZN6D github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/scalr/go-scalr v0.0.0-20220315151045-419324345753 h1:tDvuhVPeAturdg61Lc7aNIEgrbeQDpDZ9p50GRSb67k= +github.com/scalr/go-scalr v0.0.0-20220315151045-419324345753/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661 h1:DnvLMEoIGdre8txCto7ml8mvI/LcIA+uqtdhXRDUY3o= github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106 h1:2eJf0QIg5LpWqRVULkePfcvofFKid+pcHVDyhf6Jnfw= github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220510081837-08679c781ac8 h1:74hZj6K4gtNh0EHZyMS8j0+yVCMVpE0rXx5hWRf7n/Q= +github.com/scalr/go-scalr v0.0.0-20220510081837-08679c781ac8/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe h1:Gq6oYYwAe6b70HtxwG+3mfim87sHsZJVkE1DErQk2qY= +github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From f95d89bafaa08b7395f216e8e0da39343f70b620 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Tue, 10 May 2022 11:52:56 +0300 Subject: [PATCH 24/50] SCALRCORE-18405 update go.mod and go.sum --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 89a23362..15983b5b 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a + github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe ) require ( diff --git a/go.sum b/go.sum index 8f826e9a..45af9ffe 100644 --- a/go.sum +++ b/go.sum @@ -305,6 +305,8 @@ github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106 h1:2eJf0QIg5LpWqRVU github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a h1:P4ANn4rx4tmVLUIIm5V0hUkR0eTUImyhtla8SE1EVhc= github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe h1:Gq6oYYwAe6b70HtxwG+3mfim87sHsZJVkE1DErQk2qY= +github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From 732f6925dda53f864218ff1e90ddd31ecc5f640d Mon Sep 17 00:00:00 2001 From: Artem Vang Date: Tue, 10 May 2022 12:23:10 +0300 Subject: [PATCH 25/50] SCALRCORE-21545 > Add step for uploading package to dev registry --- .github/workflows/default.yml | 40 +++++++++++++++++++++++++++++++++++ scripts/upload.sh | 8 ++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index ac232d8e..94d786be 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -70,6 +70,46 @@ jobs: with: command: delete container_id: ${{ steps.create.outputs.container_id }} + upload-dev: + name: upload-dev + needs: [lint, unit-tests, acc-tests] + runs-on: ubuntu-latest + steps: + - name: Import GPG key + id: import_gpg + uses: Scalr/ghaction-import-gpg@v2.1.1 + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v0 + with: + project_id: ${{ secrets.GCP_PROJECT_ID }} + service_account_key: ${{ secrets.GCP_SA_KEY }} + export_default_credentials: true + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: "1.17" + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + - name: Upload provider to registry + env: + DOMAIN: registry.scalr.dev + BUCKET_NAME: gs://tf-registry-48e84b05eab87d56 + GPG_KEY_ID: ${{ steps.import_gpg.outputs.fingerprint }} + GPG_PUB_KEY: ${{ steps.import_gpg.outputs.pubkey }} + run: bash scripts/upload.sh release: name: release if: startsWith(github.ref, 'refs/tags/') diff --git a/scripts/upload.sh b/scripts/upload.sh index 7d3a0702..2c3ad6e4 100755 --- a/scripts/upload.sh +++ b/scripts/upload.sh @@ -10,8 +10,14 @@ PROVIDER_SOURCE="scalr/scalr" URL="https://$DOMAIN" PROTOCOLS="[\"5.0\"]" +# If tag is not defined, use branch name as version VERSION=$(PAGER= git tag --points-at HEAD) -VERSION=${VERSION:1} +if [ -z "$VERSION" ]; then + VERSION=$(git rev-parse --abbrev-ref HEAD | sed 's|\(.*\)|\L\1|g;s|/|-|g') +else + VERSION=${VERSION:1} +fi + TMP_DIR=$(mktemp -d -t scalr-provider-$VERSION-XXXXXXXXXXX) PROVIDER_BIN_PATH=$TMP_DIR/$PROVIDER_NAME/$VERSION DOWNLOAD_DIR=$TMP_DIR/$PROVIDER_SOURCE/$VERSION/download/ From 46101b0ec6b9cef8b24931111b218b98e178a50d Mon Sep 17 00:00:00 2001 From: Artem Vang Date: Tue, 10 May 2022 12:41:37 +0300 Subject: [PATCH 26/50] SCALRCORE-21545 > Replace release with build --- .github/workflows/default.yml | 18 +++++++++++------- scripts/upload.sh | 8 +------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 94d786be..8e5f0976 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -84,13 +84,18 @@ jobs: - name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v0 with: - project_id: ${{ secrets.GCP_PROJECT_ID }} - service_account_key: ${{ secrets.GCP_SA_KEY }} + project_id: ${{ secrets.DEV_GCP_PROJECT_ID }} + service_account_key: ${{ secrets.DEV_GCP_SA_KEY }} export_default_credentials: true - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 + - name: Create dev-tag + run: | + LAST_TAG=$(git describe --tags --abbrev=0) + BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's|\(.*\)|\L\1|g;s|/|-|g') + git tag $LAST_TAG-$BRANCH - name: Set up Go uses: actions/setup-go@v2 with: @@ -98,15 +103,14 @@ jobs: - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: - version: latest - args: release --rm-dist + version: v1.8.3 + args: release --skip-publish env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} - name: Upload provider to registry env: - DOMAIN: registry.scalr.dev - BUCKET_NAME: gs://tf-registry-48e84b05eab87d56 + DOMAIN: ${{ secrets.DEV_DOMAIN }} + BUCKET_NAME: ${{ secrets.DEV_BUCKET_NAME }} GPG_KEY_ID: ${{ steps.import_gpg.outputs.fingerprint }} GPG_PUB_KEY: ${{ steps.import_gpg.outputs.pubkey }} run: bash scripts/upload.sh diff --git a/scripts/upload.sh b/scripts/upload.sh index 2c3ad6e4..7d3a0702 100755 --- a/scripts/upload.sh +++ b/scripts/upload.sh @@ -10,14 +10,8 @@ PROVIDER_SOURCE="scalr/scalr" URL="https://$DOMAIN" PROTOCOLS="[\"5.0\"]" -# If tag is not defined, use branch name as version VERSION=$(PAGER= git tag --points-at HEAD) -if [ -z "$VERSION" ]; then - VERSION=$(git rev-parse --abbrev-ref HEAD | sed 's|\(.*\)|\L\1|g;s|/|-|g') -else - VERSION=${VERSION:1} -fi - +VERSION=${VERSION:1} TMP_DIR=$(mktemp -d -t scalr-provider-$VERSION-XXXXXXXXXXX) PROVIDER_BIN_PATH=$TMP_DIR/$PROVIDER_NAME/$VERSION DOWNLOAD_DIR=$TMP_DIR/$PROVIDER_SOURCE/$VERSION/download/ From 2746064d7d9dfe2d854087bfc8f814d6ede6d1e3 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Tue, 10 May 2022 16:38:38 +0300 Subject: [PATCH 27/50] SCALRCORE-21894 delete omitempty tag for workspace vcs-repo --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 15983b5b..d2e7fb99 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe + github.com/scalr/go-scalr v0.0.0-20220510133017-1bc7853bdbbd ) require ( diff --git a/go.sum b/go.sum index 45af9ffe..842fde69 100644 --- a/go.sum +++ b/go.sum @@ -307,6 +307,8 @@ github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a h1:P4ANn4rx4tmVLUII github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe h1:Gq6oYYwAe6b70HtxwG+3mfim87sHsZJVkE1DErQk2qY= github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220510133017-1bc7853bdbbd h1:PCzkYpwjwLHtKrxahMHbuwEkyZWp3bXGi8E62Neg1ug= +github.com/scalr/go-scalr v0.0.0-20220510133017-1bc7853bdbbd/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From d83eecb08cc4cf4b54d50ba7285ca7d6c8ce3449 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Tue, 10 May 2022 17:02:37 +0300 Subject: [PATCH 28/50] SCALRCORE-21894 update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ef133b3..0b7955a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed +- `scalr_workspace`: fixed update workspace when vcs_repo is not passed ([#130](https://github.com/Scalr/terraform-provider-scalr/pull/130)) - `scalr_policy_group`: remove environments and workspaces as includes ([#125](https://github.com/Scalr/terraform-provider-scalr/pull/125)) ## [1.0.0-rc28] - 2022-04-01 From 6e4ef14a069ac38dff61f2d3ac0adb2068b5413c Mon Sep 17 00:00:00 2001 From: Artem Vang Date: Wed, 11 May 2022 12:34:14 +0300 Subject: [PATCH 29/50] SCALRCORE-21545 > Fix providers version namings --- .github/workflows/default.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 8e5f0976..8b32c0e8 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -95,7 +95,7 @@ jobs: run: | LAST_TAG=$(git describe --tags --abbrev=0) BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's|\(.*\)|\L\1|g;s|/|-|g') - git tag $LAST_TAG-$BRANCH + git tag v1.0.0-rc-$BRANCH - name: Set up Go uses: actions/setup-go@v2 with: From da171108368e46b1e8a934c3c6bb93253577394d Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Thu, 12 May 2022 14:34:02 +0300 Subject: [PATCH 30/50] SCALRCORE-21894 delete omitempty tag for workspace vcs-provider --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d2e7fb99..efa081ba 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220510133017-1bc7853bdbbd + github.com/scalr/go-scalr v0.0.0-20220512113143-ef0e8bccfde7 ) require ( diff --git a/go.sum b/go.sum index 842fde69..6c9b89c7 100644 --- a/go.sum +++ b/go.sum @@ -309,6 +309,8 @@ github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe h1:Gq6oYYwAe6b70Htx github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220510133017-1bc7853bdbbd h1:PCzkYpwjwLHtKrxahMHbuwEkyZWp3bXGi8E62Neg1ug= github.com/scalr/go-scalr v0.0.0-20220510133017-1bc7853bdbbd/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220512113143-ef0e8bccfde7 h1:RxhSr6OqSGdHryMgF6XcDixnFUNxyWIikIQdQrkUcAk= +github.com/scalr/go-scalr v0.0.0-20220512113143-ef0e8bccfde7/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From f0f3e68058e2c03a44cdef59740cacc29ca045af Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Fri, 13 May 2022 12:38:06 +0300 Subject: [PATCH 31/50] =?UTF-8?q?SCALRCORE-21894=20make=20vcs-provider=20a?= =?UTF-8?q?nd=20vcs-repo=20=D0=BA=D1=83=D0=B9=D0=B3=D1=88=D0=BA=D1=83?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- scalr/resource_scalr_workspace.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b7955a9..c0b00da6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed -- `scalr_workspace`: fixed update workspace when vcs_repo is not passed ([#130](https://github.com/Scalr/terraform-provider-scalr/pull/130)) +- `scalr_workspace`: vcs_repo and vcs_provider_id have to passed together ([#130](https://github.com/Scalr/terraform-provider-scalr/pull/130)) - `scalr_policy_group`: remove environments and workspaces as includes ([#125](https://github.com/Scalr/terraform-provider-scalr/pull/125)) ## [1.0.0-rc28] - 2022-04-01 diff --git a/scalr/resource_scalr_workspace.go b/scalr/resource_scalr_workspace.go index 73892151..b9df8d6c 100644 --- a/scalr/resource_scalr_workspace.go +++ b/scalr/resource_scalr_workspace.go @@ -54,6 +54,7 @@ func resourceScalrWorkspace() *schema.Resource { Type: schema.TypeString, Optional: true, ConflictsWith: []string{"module_version_id"}, + RequiredWith: []string{"vcs_repo"}, }, "module_version_id": { Type: schema.TypeString, @@ -138,6 +139,7 @@ func resourceScalrWorkspace() *schema.Resource { MinItems: 1, MaxItems: 1, ConflictsWith: []string{"module_version_id"}, + RequiredWith: []string{"vcs_provider_id"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "identifier": { From 260a1fbabb850fd8bdacd2b8b12007f83862a446 Mon Sep 17 00:00:00 2001 From: Edhar Mocharnyk Date: Fri, 13 May 2022 15:52:57 +0300 Subject: [PATCH 32/50] update CHANGELOG.md and scalr_workspace_run_schedule.md --- CHANGELOG.md | 13 +++++++++++-- docs/resources/scalr_workspace_run_schedule.md | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ef133b3..171bc3f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.0-rc29] - 2022-05-13 +### Added +scalr_workspace_run_schedule +- **New resource:** `scalr_workspace_run_schedule` ([#124](https://github.com/Scalr/terraform-provider-scalr/pull/124)) + +### Changed +- `scalr_workspace`: added new attribute `var_files` ([#118](https://github.com/Scalr/terraform-provider-scalr/pull/118)) + ### Fixed - `scalr_policy_group`: remove environments and workspaces as includes ([#125](https://github.com/Scalr/terraform-provider-scalr/pull/125)) +- `scalr_variable`: updated the confusing error for multi-scope variables ([#119](https://github.com/Scalr/terraform-provider-scalr/pull/119)) ## [1.0.0-rc28] - 2022-04-01 @@ -19,7 +28,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `scalr_workspace`: added a new attribute `run_operation_timeout` ([#115](https://github.com/Scalr/terraform-provider-scalr/pull/115)) ### Changed -- `scalr_workspace`: added new attribute `var_files` ([#118](https://github.com/Scalr/terraform-provider-scalr/pull/118)) - `resource.scalr_role`: added new state migration (include `accounts:set-quotas` permission if needed) ([#116](https://github.com/Scalr/terraform-provider-scalr/pull/108)) ### Fixed @@ -402,7 +410,8 @@ Requires Scalr 8.0.1-beta.20200625 at least - Initial release. -[Unreleased]: https://github.com/Scalr/terraform-provider-scalr/compare/v1.0.0-rc28...HEAD +[Unreleased]: https://github.com/Scalr/terraform-provider-scalr/compare/v1.0.0-rc29...HEAD +[1.0.0-rc29]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc29 [1.0.0-rc28]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc28 [1.0.0-rc27]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc27 [1.0.0-rc26]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc26 diff --git a/docs/resources/scalr_workspace_run_schedule.md b/docs/resources/scalr_workspace_run_schedule.md index 2ad21ae0..fd71f454 100644 --- a/docs/resources/scalr_workspace_run_schedule.md +++ b/docs/resources/scalr_workspace_run_schedule.md @@ -8,15 +8,25 @@ Manages run schedules. # scalr_workspace_run_schedule Resource -Manage the state of workspace run schedules in Scalr. Create, update and destroy +Allows workspace admins to automate the configuration of recurring runs for a workspace. ## Example Usage Basic usage: ```hcl +data scalr_environment "current" { + account_id = "acc-12345" + name = "dev" +} + +data "scalr_workspace" "cert" { + environment_id = data.scalr_environment.current.id + name = "ssl-certificates" +} + resource "scalr_workspace_run_schedule" "example" { - workspace_id = "ws-xxxxxx" + workspace_id = data.scalr_workspace.cert.id apply_schedule = "30 3 5 3-5 2" destroy_schedule = "30 4 5 3-5 2" } @@ -33,5 +43,5 @@ resource "scalr_workspace_run_schedule" "example" { All arguments plus: -* `id` - The workspaces's ID, in the format `ws-`. +* `id` - The identifier of a workspace in the format `ws-`. From d5a59b80a613f6b6578a2e9957e35faa5da5ba90 Mon Sep 17 00:00:00 2001 From: Artem Vang Date: Fri, 13 May 2022 18:39:32 +0300 Subject: [PATCH 33/50] SCALRCORE-22008 > Check for tag name in relese job --- .github/workflows/default.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index a49a6f78..246de605 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -115,7 +115,7 @@ jobs: run: bash scripts/upload.sh release: name: release - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/v1.0.0-rc') && github.event.base_ref == 'refs/heads/develop' needs: [lint, unit-tests, acc-tests] runs-on: ubuntu-latest steps: @@ -153,4 +153,4 @@ jobs: BUCKET_NAME: ${{ secrets.BUCKET_NAME }} GPG_KEY_ID: ${{ steps.import_gpg.outputs.fingerprint }} GPG_PUB_KEY: ${{ steps.import_gpg.outputs.pubkey }} - run: bash scripts/upload.sh + run: bash scripts/upload.sh \ No newline at end of file From 3b35f0ae65f618b1875066d7f4b464bdd26539cd Mon Sep 17 00:00:00 2001 From: Artem Vang Date: Fri, 13 May 2022 18:44:40 +0300 Subject: [PATCH 34/50] SCALRCORE-22008 > Dummy commit --- .github/workflows/default.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 246de605..2743a561 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -115,7 +115,7 @@ jobs: run: bash scripts/upload.sh release: name: release - if: startsWith(github.ref, 'refs/tags/v1.0.0-rc') && github.event.base_ref == 'refs/heads/develop' + if: startsWith(github.ref, 'refs/tags/v1.0.0-rc') needs: [lint, unit-tests, acc-tests] runs-on: ubuntu-latest steps: @@ -153,4 +153,4 @@ jobs: BUCKET_NAME: ${{ secrets.BUCKET_NAME }} GPG_KEY_ID: ${{ steps.import_gpg.outputs.fingerprint }} GPG_PUB_KEY: ${{ steps.import_gpg.outputs.pubkey }} - run: bash scripts/upload.sh \ No newline at end of file + run: bash scripts/upload.sh From 9f6f9754cc2d068b27ab35fa0b2e580f1e99270f Mon Sep 17 00:00:00 2001 From: Artem Vang Date: Mon, 16 May 2022 13:20:00 +0300 Subject: [PATCH 35/50] SCALRCORE-22008 > Use gh action to validate tag, fix script to use version produced from goreleaser --- .github/workflows/default.yml | 6 +++++- scripts/upload.sh | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 2743a561..d1f2fdf9 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -115,10 +115,14 @@ jobs: run: bash scripts/upload.sh release: name: release - if: startsWith(github.ref, 'refs/tags/v1.0.0-rc') + if: startsWith(github.ref, 'refs/tags/') needs: [lint, unit-tests, acc-tests] runs-on: ubuntu-latest steps: + - name: Validate tag + uses: rubenesp87/semver-validation-action@0.0.6 + with: + version: ${{ github.event.release.tag_name }} - name: Import GPG key id: import_gpg uses: Scalr/ghaction-import-gpg@v2.1.1 diff --git a/scripts/upload.sh b/scripts/upload.sh index 7d3a0702..fc7bed5e 100755 --- a/scripts/upload.sh +++ b/scripts/upload.sh @@ -10,12 +10,14 @@ PROVIDER_SOURCE="scalr/scalr" URL="https://$DOMAIN" PROTOCOLS="[\"5.0\"]" -VERSION=$(PAGER= git tag --points-at HEAD) -VERSION=${VERSION:1} + +VERSION=$(ls dist | grep _SHA256SUMS | sed -n 's/^terraform-provider-scalr_\(.*\)_SHA256SUMS/\1/p') TMP_DIR=$(mktemp -d -t scalr-provider-$VERSION-XXXXXXXXXXX) PROVIDER_BIN_PATH=$TMP_DIR/$PROVIDER_NAME/$VERSION DOWNLOAD_DIR=$TMP_DIR/$PROVIDER_SOURCE/$VERSION/download/ +echo "Starting to push $PROVIDER_NAME:$VERSION" + # Copy remote provider registry to working directory. # Old versions of terraform provider is using for composing versions file gsutil -m rsync -R $BUCKET_NAME $TMP_DIR From 8a58bd07f8690fa0ec648cec6bc4078e2f756801 Mon Sep 17 00:00:00 2001 From: Artem Vang Date: Mon, 16 May 2022 20:59:31 +0300 Subject: [PATCH 36/50] test commit --- .github/workflows/default.yml | 4 ++-- scripts/upload.sh | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index d1f2fdf9..233b7477 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -116,13 +116,13 @@ jobs: release: name: release if: startsWith(github.ref, 'refs/tags/') - needs: [lint, unit-tests, acc-tests] + # needs: [lint, unit-tests, acc-tests] runs-on: ubuntu-latest steps: - name: Validate tag uses: rubenesp87/semver-validation-action@0.0.6 with: - version: ${{ github.event.release.tag_name }} + version: ${{ github.ref_name }} - name: Import GPG key id: import_gpg uses: Scalr/ghaction-import-gpg@v2.1.1 diff --git a/scripts/upload.sh b/scripts/upload.sh index fc7bed5e..ec7e9ef3 100755 --- a/scripts/upload.sh +++ b/scripts/upload.sh @@ -11,13 +11,15 @@ URL="https://$DOMAIN" PROTOCOLS="[\"5.0\"]" -VERSION=$(ls dist | grep _SHA256SUMS | sed -n 's/^terraform-provider-scalr_\(.*\)_SHA256SUMS/\1/p') +VERSION=$(ls dist | grep '_SHA256SUMS$' | sed -n 's/^terraform-provider-scalr_\(.*\)_SHA256SUMS/\1/p') TMP_DIR=$(mktemp -d -t scalr-provider-$VERSION-XXXXXXXXXXX) PROVIDER_BIN_PATH=$TMP_DIR/$PROVIDER_NAME/$VERSION DOWNLOAD_DIR=$TMP_DIR/$PROVIDER_SOURCE/$VERSION/download/ echo "Starting to push $PROVIDER_NAME:$VERSION" +exit + # Copy remote provider registry to working directory. # Old versions of terraform provider is using for composing versions file gsutil -m rsync -R $BUCKET_NAME $TMP_DIR From 6da02aa30a8bfbaef1df5171a5bfa349658a356e Mon Sep 17 00:00:00 2001 From: Artem Vang Date: Mon, 16 May 2022 21:54:02 +0300 Subject: [PATCH 37/50] SCALRCORE-22008 > Revert back test env, use semver validator from goreleaser --- .github/workflows/default.yml | 6 +----- scripts/upload.sh | 2 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 233b7477..a49a6f78 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -116,13 +116,9 @@ jobs: release: name: release if: startsWith(github.ref, 'refs/tags/') - # needs: [lint, unit-tests, acc-tests] + needs: [lint, unit-tests, acc-tests] runs-on: ubuntu-latest steps: - - name: Validate tag - uses: rubenesp87/semver-validation-action@0.0.6 - with: - version: ${{ github.ref_name }} - name: Import GPG key id: import_gpg uses: Scalr/ghaction-import-gpg@v2.1.1 diff --git a/scripts/upload.sh b/scripts/upload.sh index ec7e9ef3..75eec002 100755 --- a/scripts/upload.sh +++ b/scripts/upload.sh @@ -18,8 +18,6 @@ DOWNLOAD_DIR=$TMP_DIR/$PROVIDER_SOURCE/$VERSION/download/ echo "Starting to push $PROVIDER_NAME:$VERSION" -exit - # Copy remote provider registry to working directory. # Old versions of terraform provider is using for composing versions file gsutil -m rsync -R $BUCKET_NAME $TMP_DIR From 14658f310a35de2dbda3104fb6e4cafd1f9da5e3 Mon Sep 17 00:00:00 2001 From: Roman <37997220+RomanMytsko@users.noreply.github.com> Date: Tue, 17 May 2022 09:00:38 +0300 Subject: [PATCH 38/50] Update CHANGELOG.md Co-authored-by: Anatoliy Brezitskiy --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0b00da6..bf72c1ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed -- `scalr_workspace`: vcs_repo and vcs_provider_id have to passed together ([#130](https://github.com/Scalr/terraform-provider-scalr/pull/130)) +- `scalr_workspace`: vcs_repo and vcs_provider_id have to be passed simultaneously ([#130](https://github.com/Scalr/terraform-provider-scalr/pull/130)) - `scalr_policy_group`: remove environments and workspaces as includes ([#125](https://github.com/Scalr/terraform-provider-scalr/pull/125)) ## [1.0.0-rc28] - 2022-04-01 From 62fc955673f60144b9ca7f536fff1082c09e4d48 Mon Sep 17 00:00:00 2001 From: soltysss Date: Tue, 17 May 2022 12:41:25 +0300 Subject: [PATCH 39/50] SCALRCORE-20543 - API > link environment to policy group optimization [API_BRANCH] --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 15983b5b..89caedae 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe + github.com/scalr/go-scalr v0.0.0-20220506112707-49f02107d87e ) require ( diff --git a/go.sum b/go.sum index 45af9ffe..66c8227f 100644 --- a/go.sum +++ b/go.sum @@ -305,6 +305,8 @@ github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106 h1:2eJf0QIg5LpWqRVU github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a h1:P4ANn4rx4tmVLUIIm5V0hUkR0eTUImyhtla8SE1EVhc= github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220506112707-49f02107d87e h1:5ZiAqi2rN1/0qCc7zRzsEY4ZtZteDcpkbqXiiRecRr4= +github.com/scalr/go-scalr v0.0.0-20220506112707-49f02107d87e/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe h1:Gq6oYYwAe6b70HtxwG+3mfim87sHsZJVkE1DErQk2qY= github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= From 55a510c3d88ed292c6d758117263278a6323631e Mon Sep 17 00:00:00 2001 From: soltysss Date: Tue, 17 May 2022 13:46:33 +0300 Subject: [PATCH 40/50] SCALRCORE-20543 - API > link environment to policy group optimization [API_BRANCH] --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 89caedae..e0943179 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220506112707-49f02107d87e + github.com/scalr/go-scalr v0.0.0-20220517102326-518c471bd8cb ) require ( diff --git a/go.sum b/go.sum index 66c8227f..49676cb3 100644 --- a/go.sum +++ b/go.sum @@ -309,6 +309,8 @@ github.com/scalr/go-scalr v0.0.0-20220506112707-49f02107d87e h1:5ZiAqi2rN1/0qCc7 github.com/scalr/go-scalr v0.0.0-20220506112707-49f02107d87e/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe h1:Gq6oYYwAe6b70HtxwG+3mfim87sHsZJVkE1DErQk2qY= github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220517102326-518c471bd8cb h1:wT68qRSmY/xEY+ta2EbJxgMfII/U1g7cqcJH1yKIS+M= +github.com/scalr/go-scalr v0.0.0-20220517102326-518c471bd8cb/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From b2d5077d2a1527858f830f3f536570ad5b7fff5b Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Tue, 17 May 2022 17:17:18 +0300 Subject: [PATCH 41/50] SCALRCORE-21894 CR fixes -> add tests --- scalr/resource_scalr_workspace_test.go | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/scalr/resource_scalr_workspace_test.go b/scalr/resource_scalr_workspace_test.go index 93978bf1..8119c2f0 100644 --- a/scalr/resource_scalr_workspace_test.go +++ b/scalr/resource_scalr_workspace_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "log" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -245,6 +246,18 @@ func TestAccScalrWorkspace_update(t *testing.T) { "scalr_workspace.test", "working_directory", ""), ), }, + + { + Config: testAccScalrWorkspaceUpdateVcsRepo(rInt), + ExpectError: regexp.MustCompile("config is invalid: \"vcs_repo\": all of `vcs_provider_id,vcs_repo` must be specified"), + PlanOnly: true, + }, + + { + Config: testAccScalrWorkspaceUpdateVcsProvider(rInt), + ExpectError: regexp.MustCompile("config is invalid: \"vcs_provider_id\": all of `vcs_provider_id,vcs_repo` must be specified"), + PlanOnly: true, + }, }, }) } @@ -495,6 +508,33 @@ resource "scalr_workspace" "test" { }`) } +func testAccScalrWorkspaceUpdateVcsRepo(rInt int) string { + return fmt.Sprintf(testAccScalrWorkspaceCommonConfig, rInt, defaultAccount, ` +resource "scalr_workspace" "test" { + environment_id = scalr_environment.test.id + auto_apply = false + operations = false + terraform_version = "0.12.19" + working_directory = "terraform/test" + vcs_repo { + identifier = "RomanMytsko/local_exec" + branch = "main" + } +}`) +} + +func testAccScalrWorkspaceUpdateVcsProvider(rInt int) string { + return fmt.Sprintf(testAccScalrWorkspaceCommonConfig, rInt, defaultAccount, ` +resource "scalr_workspace" "test" { + environment_id = scalr_environment.test.id + auto_apply = false + operations = false + terraform_version = "0.12.19" + working_directory = "terraform/test" + vcs_provider_id = "test_provider_id" +}`) +} + func testAccScalrWorkspaceUpdateWithoutHooks(rInt int) string { return fmt.Sprintf(testAccScalrWorkspaceCommonConfig, rInt, defaultAccount, ` resource "scalr_workspace" "test" { From 543710488ba9de3c55ba65034c5d4546bed63d15 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Tue, 17 May 2022 17:28:13 +0300 Subject: [PATCH 42/50] SCALRCORE-21894 CR fixes --- scalr/resource_scalr_workspace_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scalr/resource_scalr_workspace_test.go b/scalr/resource_scalr_workspace_test.go index 8119c2f0..2bc814c8 100644 --- a/scalr/resource_scalr_workspace_test.go +++ b/scalr/resource_scalr_workspace_test.go @@ -511,6 +511,7 @@ resource "scalr_workspace" "test" { func testAccScalrWorkspaceUpdateVcsRepo(rInt int) string { return fmt.Sprintf(testAccScalrWorkspaceCommonConfig, rInt, defaultAccount, ` resource "scalr_workspace" "test" { + name = "workspace-updated" environment_id = scalr_environment.test.id auto_apply = false operations = false @@ -526,6 +527,7 @@ resource "scalr_workspace" "test" { func testAccScalrWorkspaceUpdateVcsProvider(rInt int) string { return fmt.Sprintf(testAccScalrWorkspaceCommonConfig, rInt, defaultAccount, ` resource "scalr_workspace" "test" { + name = "workspace-updated" environment_id = scalr_environment.test.id auto_apply = false operations = false From e95b959f9f499bb4ee0fd1cfd6f8726e13d9b198 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Wed, 18 May 2022 14:42:24 +0300 Subject: [PATCH 43/50] SCALRCORE-21894 CR fixes --- scalr/resource_scalr_workspace_test.go | 39 +++++++++++++++----------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/scalr/resource_scalr_workspace_test.go b/scalr/resource_scalr_workspace_test.go index 2bc814c8..a06a2eac 100644 --- a/scalr/resource_scalr_workspace_test.go +++ b/scalr/resource_scalr_workspace_test.go @@ -58,6 +58,25 @@ func TestAccScalrWorkspace_basic(t *testing.T) { }) } +func TestAccScalrWorkspace_create_missed_vcs_attr(t *testing.T) { + rInt := GetRandomInteger() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccScalrWorkspaceMissedVcsProvider(rInt), + ExpectError: regexp.MustCompile("config is invalid: \"vcs_repo\": all of `vcs_provider_id,vcs_repo` must be specified"), + }, + { + Config: testAccScalrWorkspaceMissedVcsRepo(rInt), + ExpectError: regexp.MustCompile("config is invalid: \"vcs_provider_id\": all of `vcs_provider_id,vcs_repo` must be specified"), + }, + }, + }) +} + func TestAccScalrWorkspace_monorepo(t *testing.T) { workspace := &scalr.Workspace{} rInt := GetRandomInteger() @@ -246,18 +265,6 @@ func TestAccScalrWorkspace_update(t *testing.T) { "scalr_workspace.test", "working_directory", ""), ), }, - - { - Config: testAccScalrWorkspaceUpdateVcsRepo(rInt), - ExpectError: regexp.MustCompile("config is invalid: \"vcs_repo\": all of `vcs_provider_id,vcs_repo` must be specified"), - PlanOnly: true, - }, - - { - Config: testAccScalrWorkspaceUpdateVcsProvider(rInt), - ExpectError: regexp.MustCompile("config is invalid: \"vcs_provider_id\": all of `vcs_provider_id,vcs_repo` must be specified"), - PlanOnly: true, - }, }, }) } @@ -508,7 +515,7 @@ resource "scalr_workspace" "test" { }`) } -func testAccScalrWorkspaceUpdateVcsRepo(rInt int) string { +func testAccScalrWorkspaceMissedVcsProvider(rInt int) string { return fmt.Sprintf(testAccScalrWorkspaceCommonConfig, rInt, defaultAccount, ` resource "scalr_workspace" "test" { name = "workspace-updated" @@ -518,13 +525,13 @@ resource "scalr_workspace" "test" { terraform_version = "0.12.19" working_directory = "terraform/test" vcs_repo { - identifier = "RomanMytsko/local_exec" - branch = "main" + identifier = "TestRepo/local" + branch = "main" } }`) } -func testAccScalrWorkspaceUpdateVcsProvider(rInt int) string { +func testAccScalrWorkspaceMissedVcsRepo(rInt int) string { return fmt.Sprintf(testAccScalrWorkspaceCommonConfig, rInt, defaultAccount, ` resource "scalr_workspace" "test" { name = "workspace-updated" From 49f18390eb6f9c82d49d9b8012a1b98ad35d9199 Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Mon, 23 May 2022 11:34:11 +0300 Subject: [PATCH 44/50] SCALRCORE-21894 fix go files --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index efa081ba..04a275bf 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 - github.com/scalr/go-scalr v0.0.0-20220512113143-ef0e8bccfde7 + github.com/scalr/go-scalr v0.0.0-20220523083310-b14d71171237 ) require ( diff --git a/go.sum b/go.sum index 1c940708..909f2ae2 100644 --- a/go.sum +++ b/go.sum @@ -313,6 +313,8 @@ github.com/scalr/go-scalr v0.0.0-20220512113143-ef0e8bccfde7 h1:RxhSr6OqSGdHryMg github.com/scalr/go-scalr v0.0.0-20220512113143-ef0e8bccfde7/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220517102326-518c471bd8cb h1:wT68qRSmY/xEY+ta2EbJxgMfII/U1g7cqcJH1yKIS+M= github.com/scalr/go-scalr v0.0.0-20220517102326-518c471bd8cb/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= +github.com/scalr/go-scalr v0.0.0-20220523083310-b14d71171237 h1:M9d2EOzFFBe/9fqkYpEKK0qKvh1RcZbA6dVWz4k3Rt8= +github.com/scalr/go-scalr v0.0.0-20220523083310-b14d71171237/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= From b1258681bf1d9bf7fd0ee17e20a2f95adad031ca Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Tue, 24 May 2022 17:29:01 +0300 Subject: [PATCH 45/50] SCALRCORE-21984 fix error msg for scalr_iam_team datasource --- scalr/data_source_scalr_iam_team.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scalr/data_source_scalr_iam_team.go b/scalr/data_source_scalr_iam_team.go index 00531548..af3ce6ec 100644 --- a/scalr/data_source_scalr_iam_team.go +++ b/scalr/data_source_scalr_iam_team.go @@ -43,7 +43,6 @@ func dataSourceScalrIamTeam() *schema.Resource { func dataSourceScalrIamTeamRead(d *schema.ResourceData, meta interface{}) error { scalrClient := meta.(*scalr.Client) - var accID string // required fields name := d.Get("name").(string) @@ -51,8 +50,10 @@ func dataSourceScalrIamTeamRead(d *schema.ResourceData, meta interface{}) error options := scalr.TeamListOptions{ Name: scalr.String(name), } - if accID, ok := d.GetOk("account_id"); ok { - options.Account = scalr.String(accID.(string)) + + accountID := d.Get("account_id").(string) + if accountID != "" { + options.Account = scalr.String(accountID) } tl, err := scalrClient.Teams.List(ctx, options) @@ -61,7 +62,7 @@ func dataSourceScalrIamTeamRead(d *schema.ResourceData, meta interface{}) error } if tl.TotalCount == 0 { - return fmt.Errorf("Could not find iam team with name %q, account_id: %q", name, accID) + return fmt.Errorf("Could not find iam team with name %q, account_id: %q", name, accountID) } if tl.TotalCount > 1 { From c445de08b34d946b595b6ec7e458d5d8281281ba Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Thu, 26 May 2022 10:26:05 +0300 Subject: [PATCH 46/50] SCALRCORE-21984 fix error msg for scalr_iam_team datasource --- scalr/data_source_scalr_iam_team.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scalr/data_source_scalr_iam_team.go b/scalr/data_source_scalr_iam_team.go index af3ce6ec..44949d82 100644 --- a/scalr/data_source_scalr_iam_team.go +++ b/scalr/data_source_scalr_iam_team.go @@ -43,6 +43,7 @@ func dataSourceScalrIamTeam() *schema.Resource { func dataSourceScalrIamTeamRead(d *schema.ResourceData, meta interface{}) error { scalrClient := meta.(*scalr.Client) + var accountID string // required fields name := d.Get("name").(string) @@ -50,9 +51,8 @@ func dataSourceScalrIamTeamRead(d *schema.ResourceData, meta interface{}) error options := scalr.TeamListOptions{ Name: scalr.String(name), } - - accountID := d.Get("account_id").(string) - if accountID != "" { + if accID, ok := d.GetOk("account_id"); ok { + accountID = accID.(string) options.Account = scalr.String(accountID) } From e509dd0175a082351e135d7934a7cfca64e8e404 Mon Sep 17 00:00:00 2001 From: Edhar Mocharnyk Date: Mon, 30 May 2022 09:35:01 +0300 Subject: [PATCH 47/50] update CHANGELOG.md --- CHANGELOG.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a00af886..03115673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.0-rc30] - 2022-05-30 + +### Fixed + +- `resource.scalr_policy_group_linkage`: optimized api interactions ([#120](https://github.com/Scalr/terraform-provider-scalr/pull/120)) +- `scalr_workspace`: vcs_repo and vcs_provider_id have to be passed simultaneously ([#130](https://github.com/Scalr/terraform-provider-scalr/pull/130)) + ## [1.0.0-rc29] - 2022-05-13 + ### Added scalr_workspace_run_schedule - **New resource:** `scalr_workspace_run_schedule` ([#124](https://github.com/Scalr/terraform-provider-scalr/pull/124)) @@ -16,7 +24,6 @@ scalr_workspace_run_schedule - `scalr_workspace`: added new attribute `var_files` ([#118](https://github.com/Scalr/terraform-provider-scalr/pull/118)) ### Fixed -- `scalr_workspace`: vcs_repo and vcs_provider_id have to be passed simultaneously ([#130](https://github.com/Scalr/terraform-provider-scalr/pull/130)) - `scalr_policy_group`: remove environments and workspaces as includes ([#125](https://github.com/Scalr/terraform-provider-scalr/pull/125)) - `scalr_variable`: updated the confusing error for multi-scope variables ([#119](https://github.com/Scalr/terraform-provider-scalr/pull/119)) @@ -35,7 +42,6 @@ scalr_workspace_run_schedule - `scalr_variable`: fix error on create terraform variable on some scope ([#119](https://github.com/Scalr/terraform-provider-scalr/pull/119)) - Correctly handle not found resources ([#117](https://github.com/Scalr/terraform-provider-scalr/pull/117)) -- `resource.scalr_policy_group_linkage`: optimized api interactions ([#120](https://github.com/Scalr/terraform-provider-scalr/pull/120)) ### Required @@ -412,7 +418,8 @@ Requires Scalr 8.0.1-beta.20200625 at least - Initial release. -[Unreleased]: https://github.com/Scalr/terraform-provider-scalr/compare/v1.0.0-rc29...HEAD +[Unreleased]: https://github.com/Scalr/terraform-provider-scalr/compare/v1.0.0-rc30...HEAD +[1.0.0-rc30]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc30 [1.0.0-rc29]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc29 [1.0.0-rc28]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc28 [1.0.0-rc27]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc27 From 1fb34f3276555ba898261e9a8419d3ddfd7a902f Mon Sep 17 00:00:00 2001 From: Roman Mytsko Date: Tue, 31 May 2022 10:51:31 +0300 Subject: [PATCH 48/50] SCALRCORE-21984 update error message --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03115673..1cb4b5d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `resource.scalr_policy_group_linkage`: optimized api interactions ([#120](https://github.com/Scalr/terraform-provider-scalr/pull/120)) - `scalr_workspace`: vcs_repo and vcs_provider_id have to be passed simultaneously ([#130](https://github.com/Scalr/terraform-provider-scalr/pull/130)) +- `scalr_iam_team`: Account id is shown in error message when trying to create `scalr_iam_team` resource and use it in datasource in parallel and without `depends_on` ([#135](https://github.com/Scalr/terraform-provider-scalr/pull/135)) ## [1.0.0-rc29] - 2022-05-13 From 48fcf5ea3d5459a7cd21712f15af93ad3c9d88d0 Mon Sep 17 00:00:00 2001 From: Marat Komarov Date: Sat, 4 Jun 2022 18:17:36 -0700 Subject: [PATCH 49/50] Closing CVE-2022-30323 --- go.mod | 4 ++-- go.sum | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 04a275bf..b6fe379a 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.5.3 // indirect + github.com/hashicorp/go-getter v1.6.1 // indirect github.com/hashicorp/go-hclog v0.9.2 // indirect github.com/hashicorp/go-multierror v1.0.0 // indirect github.com/hashicorp/go-plugin v1.3.0 // indirect @@ -77,7 +77,7 @@ require ( golang.org/x/mod v0.3.0 // indirect golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect - golang.org/x/sys v0.0.0-20210324051608-47abb6519492 // indirect + golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e // indirect golang.org/x/text v0.3.5 // indirect golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect diff --git a/go.sum b/go.sum index 909f2ae2..652f0c57 100644 --- a/go.sum +++ b/go.sum @@ -177,6 +177,8 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-getter v1.5.3 h1:NF5+zOlQegim+w/EUhSLh6QhXHmZMEeHLQzllkQ3ROU= github.com/hashicorp/go-getter v1.5.3/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= +github.com/hashicorp/go-getter v1.6.1 h1:NASsgP4q6tL94WH6nJxKWj8As2H/2kop/bB1d8JMyRY= +github.com/hashicorp/go-getter v1.6.1/go.mod h1:IZCrswsZPeWv9IkVnLElzRU/gz/QPi6pZHn4tv6vbwA= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= @@ -490,6 +492,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+vTOrIifmcYxFBx9TLg= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e h1:w36l2Uw3dRan1K3TyXriXvY+6T56GNmlKGcqiQUJDfM= +golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 00fc886d2121b5885385b992a2151c828947ff97 Mon Sep 17 00:00:00 2001 From: Marat Komarov Date: Sat, 4 Jun 2022 18:33:56 -0700 Subject: [PATCH 50/50] go mod tidy --- go.sum | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/go.sum b/go.sum index 652f0c57..08659e4b 100644 --- a/go.sum +++ b/go.sum @@ -175,7 +175,6 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.5.3 h1:NF5+zOlQegim+w/EUhSLh6QhXHmZMEeHLQzllkQ3ROU= github.com/hashicorp/go-getter v1.5.3/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= github.com/hashicorp/go-getter v1.6.1 h1:NASsgP4q6tL94WH6nJxKWj8As2H/2kop/bB1d8JMyRY= github.com/hashicorp/go-getter v1.6.1/go.mod h1:IZCrswsZPeWv9IkVnLElzRU/gz/QPi6pZHn4tv6vbwA= @@ -301,20 +300,6 @@ github.com/posener/complete v1.2.1 h1:LrvDIY//XNo65Lq84G/akBuMGlawHvGBABv8f/ZN6D github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661 h1:DnvLMEoIGdre8txCto7ml8mvI/LcIA+uqtdhXRDUY3o= -github.com/scalr/go-scalr v0.0.0-20220331085920-4ec72236c661/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= -github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106 h1:2eJf0QIg5LpWqRVULkePfcvofFKid+pcHVDyhf6Jnfw= -github.com/scalr/go-scalr v0.0.0-20220408125149-98e871983106/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= -github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a h1:P4ANn4rx4tmVLUIIm5V0hUkR0eTUImyhtla8SE1EVhc= -github.com/scalr/go-scalr v0.0.0-20220429130144-6ee1c7c3d93a/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= -github.com/scalr/go-scalr v0.0.0-20220506112707-49f02107d87e h1:5ZiAqi2rN1/0qCc7zRzsEY4ZtZteDcpkbqXiiRecRr4= -github.com/scalr/go-scalr v0.0.0-20220506112707-49f02107d87e/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= -github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe h1:Gq6oYYwAe6b70HtxwG+3mfim87sHsZJVkE1DErQk2qY= -github.com/scalr/go-scalr v0.0.0-20220510084130-4347446d3afe/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= -github.com/scalr/go-scalr v0.0.0-20220512113143-ef0e8bccfde7 h1:RxhSr6OqSGdHryMgF6XcDixnFUNxyWIikIQdQrkUcAk= -github.com/scalr/go-scalr v0.0.0-20220512113143-ef0e8bccfde7/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= -github.com/scalr/go-scalr v0.0.0-20220517102326-518c471bd8cb h1:wT68qRSmY/xEY+ta2EbJxgMfII/U1g7cqcJH1yKIS+M= -github.com/scalr/go-scalr v0.0.0-20220517102326-518c471bd8cb/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/scalr/go-scalr v0.0.0-20220523083310-b14d71171237 h1:M9d2EOzFFBe/9fqkYpEKK0qKvh1RcZbA6dVWz4k3Rt8= github.com/scalr/go-scalr v0.0.0-20220523083310-b14d71171237/go.mod h1:xMnwfer9UxugeNITZjTpQBwQ/4bw6/JdyDLpGdmyorE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= @@ -490,7 +475,6 @@ golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+vTOrIifmcYxFBx9TLg= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e h1:w36l2Uw3dRan1K3TyXriXvY+6T56GNmlKGcqiQUJDfM= golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=