Skip to content

Commit

Permalink
Merge branch 'master' into SCALRCORE-26654
Browse files Browse the repository at this point in the history
  • Loading branch information
petroprotsakh committed Dec 1, 2024
2 parents 10ef9f8 + 26a8a72 commit 928df1e
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 16 deletions.
1 change: 1 addition & 0 deletions .actions
Submodule .actions added at 9ca985
24 changes: 20 additions & 4 deletions .github/workflows/backport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ on:
- ready_for_review
- reopened
- synchronize
- labeled
- unlabeled
branches:
- 'release/*'

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
backport:
name: Backport
runs-on: [standard-1-without-dind-amd64]
runs-on: ubuntu-latest
steps:
- name: Sudo GitHub Token
id: sudo_github_token
Expand All @@ -30,12 +36,22 @@ jobs:
filter: blob:none
show-progress: false

- uses: actions/checkout@v4
with:
ref: master
sparse-checkout: |
2-pr-backport
path: .actions
repository: Scalr/actions
token: ${{steps.sudo_github_token.outputs.token}}

- name: Backport
uses: Scalr/actions/2-pr-backport@master
uses: ./.actions/2-pr-backport
with:
approval_bot_token: ${{secrets.SCALR_BUILDBOT_TOKEN}}
token: ${{steps.sudo_github_token.outputs.token}}
branches_ordering_rule: >-
release/*.*.*
master
base_branch: ${{github.base_ref}}
head_branch: ${{github.head_ref}}
base_branch: ${{github.event.pull_request.base.ref}}
head_branch: ${{github.event.pull_request.head.ref}}
58 changes: 58 additions & 0 deletions .github/workflows/pr-approval-label.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Manage Approved Label

on:
pull_request_review:
types: [submitted]

jobs:
approval-label:
runs-on: ubuntu-latest
name: Approval Label
steps:
- name: Sudo GitHub Token
id: sudo_github_token
uses: tibdex/[email protected]
with:
app_id: ${{vars.SUDO_GHA_APP_ID}}
installation_id: ${{vars.SUDO_GHA_APP_INSTALLATION_ID}}
private_key: ${{secrets.SUDO_GHA_APP_PRIVATE_KEY}}

- name: Get pr info
uses: octokit/[email protected]
id: get_pr_info
with:
variables: |
owner: "Scalr"
repo: ${{github.event.repository.name}}
pr: ${{github.event.pull_request.number}}
query: |
query ($owner: String!, $repo: String!, $pr: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
reviewDecision
timelineItems(last: 250) {
edges {
node {
__typename
}
}
}
}
}
}
env:
GITHUB_TOKEN: ${{steps.sudo_github_token.outputs.token}}

- name: Set label
if: github.event.review.state == 'approved' && fromJson(steps.get_pr_info.outputs.data).repository.pullRequest.reviewDecision == 'APPROVED'
uses: actions-ecosystem/action-add-labels@v1
with:
labels: approved
github_token: ${{steps.sudo_github_token.outputs.token}}

- name: Remove label
if: github.event.review.state != 'approved' || fromJson(steps.get_pr_info.outputs.data).repository.pullRequest.reviewDecision != 'APPROVED'
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: approved
github_token: ${{steps.sudo_github_token.outputs.token}}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Various false positive attribute drifts ([#344](https://github.com/Scalr/terraform-provider-scalr/pull/344))
- `cost_estimation_enabled` attribute is forced to `false` in the `scalr_environment` resource if this attrute is ommited in the configuration ([#366](https://github.com/Scalr/terraform-provider-scalr/pull/366))

### Changed

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ resource "scalr_environment" "test" {
### Optional

- `account_id` (String) ID of the environment account, in the format `acc-<RANDOM STRING>`.
- `cost_estimation_enabled` (Boolean, Deprecated) Set (true/false) to enable/disable cost estimation for the environment. Default `true`.
- `cost_estimation_enabled` (Boolean, Deprecated) Set (true/false) to enable/disable cost estimation for the environment.
- `default_provider_configurations` (Set of String) List of IDs of provider configurations, used in the environment workspaces by default.
- `policy_groups` (List of String, Deprecated) List of the environment policy-groups IDs, in the format `pgrp-<RANDOM STRING>`.
- `tag_ids` (Set of String) List of tag IDs associated with the environment.
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/data_source_scalr_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.scalr_environment.test", "name", fmt.Sprintf("test-env-%d", rInt)),
resource.TestCheckResourceAttr("data.scalr_environment.test", "status", "Active"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "false"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "true"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", defaultAccount),
resource.TestCheckResourceAttr("data.scalr_environment.test", "tags.#", "0"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.full_name"),
Expand All @@ -58,7 +58,7 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.scalr_environment.test", "name", fmt.Sprintf("test-env-%d", rInt)),
resource.TestCheckResourceAttr("data.scalr_environment.test", "status", "Active"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "false"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "true"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", defaultAccount),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.full_name"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.email"),
Expand All @@ -70,7 +70,7 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.scalr_environment.test", "name", fmt.Sprintf("test-env-%d", rInt)),
resource.TestCheckResourceAttr("data.scalr_environment.test", "status", "Active"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "false"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "cost_estimation_enabled", "true"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "account_id", defaultAccount),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.full_name"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.email"),
Expand Down
20 changes: 12 additions & 8 deletions internal/provider/resource_scalr_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func resourceScalrEnvironment() *schema.Resource {
Required: true,
},
"cost_estimation_enabled": {
Description: "Set (true/false) to enable/disable cost estimation for the environment. Default `true`.",
Description: "Set (true/false) to enable/disable cost estimation for the environment.",
Type: schema.TypeBool,
Computed: true,
Optional: true,
Expand Down Expand Up @@ -127,10 +127,12 @@ func resourceScalrEnvironmentCreate(ctx context.Context, d *schema.ResourceData,
}

options := scalr.EnvironmentCreateOptions{
Name: ptr(name),
CostEstimationEnabled: ptr(d.Get("cost_estimation_enabled").(bool)),
Account: &scalr.Account{ID: accountID},
PolicyGroups: policyGroups,
Name: ptr(name),
Account: &scalr.Account{ID: accountID},
PolicyGroups: policyGroups,
}
if costEstimationEnabled, ok := d.GetOkExists("cost_estimation_enabled"); ok { //nolint:staticcheck
options.CostEstimationEnabled = ptr(costEstimationEnabled.(bool))
}
if defaultProviderConfigurationsI, ok := d.GetOk("default_provider_configurations"); ok {
defaultProviderConfigurations := defaultProviderConfigurationsI.(*schema.Set).List()
Expand Down Expand Up @@ -229,9 +231,11 @@ func resourceScalrEnvironmentUpdate(ctx context.Context, d *schema.ResourceData,

// Create a new options struct.
options := scalr.EnvironmentUpdateOptions{
Name: ptr(d.Get("name").(string)),
CostEstimationEnabled: ptr(d.Get("cost_estimation_enabled").(bool)),
PolicyGroups: policyGroups,
Name: ptr(d.Get("name").(string)),
PolicyGroups: policyGroups,
}
if costEstimationEnabled, ok := d.GetOkExists("cost_estimation_enabled"); ok { //nolint:staticcheck
options.CostEstimationEnabled = ptr(costEstimationEnabled.(bool))
}

if defaultProviderConfigurationsI, ok := d.GetOk("default_provider_configurations"); ok {
Expand Down

0 comments on commit 928df1e

Please sign in to comment.