Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/SCALRCORE-…
Browse files Browse the repository at this point in the history
…19437 [API_BRANCH]
  • Loading branch information
vaniakov committed Jul 23, 2021
2 parents d657b5f + 8f93d22 commit ba0abc5
Show file tree
Hide file tree
Showing 27 changed files with 882 additions and 112 deletions.
37 changes: 26 additions & 11 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,12 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: "1.13"
- name: Environment settings
env:
API_BRANCH: ${{ contains(github.event.head_commit.message, '[API_BRANCH]') }}
DB_BRANCH: ${{ contains(github.event.head_commit.message, '[DB_BRANCH]') }}
run: |
echo "API_BRANCH=${API_BRANCH}" >> $GITHUB_ENV
echo "Set env variable from commit message: API_BRANCH=${API_BRANCH}"
echo "DB_BRANCH=${DB_BRANCH}" >> $GITHUB_ENV
echo "Set env variable from commit message: DB_BRANCH=${DB_BRANCH}"
echo BRANCH=${GITHUB_REF#refs/heads/} >> $GITHUB_ENV
echo "Set env variable: BRANCH=${GITHUB_REF#refs/heads/}"
- name: Set API_BRANCH
if: ${{ contains(github.event.head_commit.message, '[API_BRANCH]') }}
run: echo "API_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Set DB_BRANCH
if: ${{ contains(github.event.head_commit.message, '[DB_BRANCH]') }}
run: echo "DB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Create container
id: create
uses: Scalr/gh-action-revizor@master
Expand Down Expand Up @@ -79,6 +74,18 @@ jobs:
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@master
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:
Expand All @@ -94,3 +101,11 @@ jobs:
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
- name: Upload provider to registry
env:
DOMAIN: ${{ secrets.DOMAIN }}
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
54 changes: 54 additions & 0 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: upstream

on:
workflow_dispatch:
inputs:
upstream-sha:
description: "Upstream commit SHA"
required: true
api-branch:
description: "API Branch"
required: true
db-branch:
description: "DB Branch"
required: false
default: "master"

jobs:
acc-tests:
runs-on: ubuntu-latest
name: acc-tests
env:
REVIZOR_URL: ${{ secrets.REVIZOR_URL }}
REVIZOR_TOKEN: ${{ secrets.REVIZOR_TOKEN }}
ORG_ADMIN_TOKEN: ${{ secrets.ORG_ADMIN_TOKEN }}
SCALR_TOKEN: ${{ secrets.SCALR_TOKEN }}
API_BRANCH: ${{ github.event.inputs.api-branch }}
DB_BRANCH: ${{ github.event.inputs.db-branch }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.13"
- name: Create container
id: create
uses: Scalr/gh-action-revizor@master
with:
command: create
- name: Run acceptance tests
env:
SCALR_HOSTNAME: ${{ steps.create.outputs.hostname }}
run: make testacc
- name: Delete container
id: delete
if: ${{ always() && steps.create.outputs.container_id }}
uses: Scalr/gh-action-revizor@master
with:
command: delete
container_id: ${{ steps.create.outputs.container_id }}
- name: Notify upstream about success
if: ${{ success() }}
run: make notify-upstream upstream_sha=${{ github.event.inputs.upstream-sha }} state=success
- name: Notify upstream about failure
if: ${{ failure() }}
run: make notify-upstream upstream_sha=${{ github.event.inputs.upstream-sha }} state=failure
31 changes: 30 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,40 @@ builds:
- '-X github.com/scalr/terraform-provider-scalr/version.ProviderVersion={{ .Version }}'
- '-X github.com/scalr/terraform-provider-scalr/version.Branch={{ .Branch }}'
binary: '{{ .ProjectName }}_v{{ .Version }}'
goos:
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'

archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'

changelog:
skip: true

checksum:
name_template: 'checksums.txt'
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256

signs:
- artifacts: checksum
args:
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}"
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"

snapshot:
name_template: "devel"
46 changes: 45 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,47 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.0.0-rc18] - 2021-07-22
### Changed

- `scalr_workspace`: make `working_directory` attribute non-computable, set default value to `""` ([#66](https://github.com/Scalr/terraform-provider-scalr/pull/66))

### Fixed

- `scalr_variable`: fix inability to create sensitive variable ([#68](https://github.com/Scalr/terraform-provider-scalr/pull/68))
- `scalr_workspace`: fix error changing working directory of a workspace to empty: plan outputs to empty diff ([#66](https://github.com/Scalr/terraform-provider-scalr/pull/66))

### Required

- scalr server >= `8.0.1-beta.20210407`

## [1.0.0-rc17] - 2021-07-08

### Added

- `scalr_workspace`: new attribute `hooks` ([#65](https://github.com/Scalr/terraform-provider-scalr/pull/65))
- `data.scalr_workspace`: new attribute `hooks` ([#65](https://github.com/Scalr/terraform-provider-scalr/pull/65))

### Changed

- `scalr_variable`: new attribute value `shell` for `scalr_variable.category` in order to create shell variable.
`env` category value is deprecated. ([#59](https://github.com/Scalr/terraform-provider-scalr/pull/64))


## [1.0.0-rc16] - 2021-05-25

### Changed

- `scalr_variable`: make `environment_id`, `workspace_id` and `account_id` attributes computable ([#60](https://github.com/Scalr/terraform-provider-scalr/pull/62))

### Fixed

- Error changing scope for variable `var-<id>`: scope is immutable attribute

### Required

- scalr server >= `8.0.1-beta.20210407`

## [1.0.0-rc15] - 2021-04-22

### Added
Expand Down Expand Up @@ -209,7 +250,10 @@ Requires Scalr 8.0.1-beta.20200625 at least

- Initial release.

[Unreleased]: https://github.com/Scalr/terraform-provider-scalr/compare/v1.0.0-rc15...HEAD
[Unreleased]: https://github.com/Scalr/terraform-provider-scalr/compare/v1.0.0-rc18...HEAD
[1.0.0-rc18]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc18
[1.0.0-rc17]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc17
[1.0.0-rc16]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc16
[1.0.0-rc15]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc15
[1.0.0-rc14]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc14
[1.0.0-rc13]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.0-rc13
Expand Down
14 changes: 12 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ PKG_NAME=scalr
BUILD_ENV=CGO_ENABLED=0
TAG=$(shell PAGER= git tag --points-at HEAD)
BRANCH=$(subst /,-,$(shell git branch --show-current))
VERSION=1.0.2
VERSION=$(if $(TAG),$(TAG),$(BRANCH))
USER_PLUGIN_DIR_LINUX=${HOME}/.terraform.d/plugins/scalr.io/scalr/scalr/$(VERSION)/linux_amd64
USER_PLUGIN_DIR=${HOME}/.terraform.d/plugins/scalr.io/scalr/scalr/$(VERSION)/$(PLATFORM)
BIN_NAME := terraform-provider-scalr_$(VERSION)
ARGS=-ldflags='-X github.com/scalr/terraform-provider-scalr/version.ProviderVersion=$(TAG) -X github.com/scalr/terraform-provider-scalr/version.Branch=$(BRANCH)'
UPSTREAM_COMMIT_DESCRIPTION="Scalr terraform provider acceptance tests"
UPSTREAM_COMMIT_TARGET_URL = "https://github.com/Scalr/terraform-provider-scalr/actions/workflows/upstream.yml"

default: build

Expand Down Expand Up @@ -37,6 +39,14 @@ test:
testacc:
$(BUILD_ENV) TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 15m -covermode atomic -coverprofile=covprofile

notify-upstream:
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $(ORG_ADMIN_TOKEN)" \
https://api.github.com/repos/Scalr/fatmouse/statuses/$(upstream_sha) \
-d '{"context":"downstream/provider", "state":"$(state)", "description": $(UPSTREAM_COMMIT_DESCRIPTION), "target_url": $(UPSTREAM_COMMIT_TARGET_URL)}'


vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
Expand All @@ -56,4 +66,4 @@ test-compile:
exit 1; \
fi
go test -c $(TEST) $(TESTARGS)
.PHONY: build build-linux test testacc vet fmt test-compile
.PHONY: build build-linux install install-linux-user test testacc vet fmt test-compile notify-upstream
8 changes: 8 additions & 0 deletions docs/data-sources/scalr_workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ All arguments plus:
* `working_directory` - A relative path that Terraform will execute within.
* `vcs_repo` - If workspace is linked to VCS repository this block shows the details, otherwise `{}`
* `created_by` - Details of the user that created the workspace.
* `hooks` - List of the workspace's custom hooks.

The `hooks` block supports:

* `pre_plan` - Script or action configured to call before plan phase
* `post_plan` - Script or action configured to call after plan phase
* `pre_apply` - Script or action configured to call before apply phase
* `post_apply` - Script or action configured to call after apply phase

The `vcs_repo` block contains:

Expand Down
4 changes: 2 additions & 2 deletions docs/resources/scalr_variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ resource "scalr_variable" "example" {

* `key` - (Required) Key of the variable.
* `value` - (Required) Variable value.
* `category` - (Required) Indicates if this is a Terraform or environment variable. Allowed values are `terraform` or `env`.
* `hcl` - (Optional) Set (true/false) to configure the variable as a string of HCL code. Has no effect for `category = "env"` variables. Default `false`.
* `category` - (Required) Indicates if this is a Terraform or shell variable. Allowed values are `terraform` or `shell`.
* `hcl` - (Optional) Set (true/false) to configure the variable as a string of HCL code. Has no effect for `category = "shell"` variables. Default `false`.
* `sensitive` - (Optional) Set (true/false) to configure as sensitive. Sensitive variable values are not visible after being set. Default `false`.
* `final` - (Optional) Set (true/false) to configure as final. Indicates whether the variable can be overridden on a lower scope down the Scalr organizational model. Default `false`.
* `force` - (Optional) Set (true/false) to configure as force. Allows creating final variables on higher scope, even if the same variable exists on lower scope (lower is to be deleted). Default `false`.
Expand Down
23 changes: 16 additions & 7 deletions docs/resources/scalr_workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,25 @@ resource "scalr_workspace" "example" {
* `operations` - (Optional) Set (true/false) to configure workspace remote execution. When `false` workspace is only used to store state. Default `true`.
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.
* `working_directory` - (Optional) A relative path that Terraform will be run in. Defaults to the root of the repository `""`.
* `vcs_provider_id` - (Optional) ID of vcs provider - required if vcs-repo present and vice versa, in the format `vcs-<RANDOM STRING>`
* `vcs_repo` - (Optional) Settings for the workspace's VCS repository.

The `vcs_repo` block supports:

* `identifier` - (Required) A reference to your VCS repository in the format `:org/:repo`, this refers to the organization and repository in your VCS provider.
* `branch` - (Optional) The repository branch where Terraform will be run from. Default `master`.
* `path` - (Optional) The repository sub-directory that Terraform will execute from. If omitted or submitted as an empty string, this defaults to the repository's root.
* `trigger_prefixes` - (Optional) List of paths (relative to `path`), whose changes will trigger a run for the workspace using this binding when the CV is created. If omitted or submitted as an empty list, any change in `path` will trigger a new run.
The `vcs_repo` block supports:

* `identifier` - (Required) A reference to your VCS repository in the format `:org/:repo`, this refers to the organization and repository in your VCS provider.
* `branch` - (Optional) The repository branch where Terraform will be run from. Default `master`.
* `path` - (Optional) The repository sub-directory that Terraform will execute from. If omitted or submitted as an empty string, this defaults to the repository's root.
* `trigger_prefixes` - (Optional) List of paths (relative to `path`), whose changes will trigger a run for the workspace using this binding when the CV is created. If omitted or submitted as an empty list, any change in `path` will trigger a new run.

* `hooks` - (Optional) Settings for the workspace's custom hooks.

The `hooks` block supports:

* `pre_plan` - (Optional) Action that will be called before plan phase
* `post_plan` - (Optional) Action that will be called after plan phase
* `pre_apply` - (Optional) Action that will be called before apply phase
* `post_apply` - (Optional) Action that will be called after apply phase

## Attribute Reference

Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ github.com/scalr/go-scalr v0.0.0-20210210153908-cc4b896f1392 h1:5omVbEGt+45vY40j
github.com/scalr/go-scalr v0.0.0-20210210153908-cc4b896f1392/go.mod h1:n2HQ6QxqyTySiSFTOpAL18SjCKtP+xUskMygO0KuuQU=
github.com/scalr/go-scalr v0.0.0-20210409150119-91a63924ba82 h1:+0Kh6Q4S9ZIGg87P3ARTOKXj04ODKEZnd+5czs9VHJE=
github.com/scalr/go-scalr v0.0.0-20210409150119-91a63924ba82/go.mod h1:n2HQ6QxqyTySiSFTOpAL18SjCKtP+xUskMygO0KuuQU=
github.com/scalr/go-scalr v0.0.0-20210609115955-0d6bc85a9297 h1:x7jZGw5uLEBkG1u1vqrW1HPJqXN79/d36SxURZFFLqc=
github.com/scalr/go-scalr v0.0.0-20210609115955-0d6bc85a9297/go.mod h1:n2HQ6QxqyTySiSFTOpAL18SjCKtP+xUskMygO0KuuQU=
github.com/scalr/go-scalr v0.0.0-20210707121246-c8ac98a29435 h1:uDCiMP8FjeWzLPbRnyntXjK3Y2Ff7yQRa0y4eUTl9/w=
github.com/scalr/go-scalr v0.0.0-20210707121246-c8ac98a29435/go.mod h1:n2HQ6QxqyTySiSFTOpAL18SjCKtP+xUskMygO0KuuQU=
github.com/scalr/go-scalr v0.0.0-20210723170605-e2860f00aea6 h1:53n0c4wFLnhA4YuALdK7GRixBJlVF+pQ7U1TCQV46/0=
github.com/scalr/go-scalr v0.0.0-20210723170605-e2860f00aea6/go.mod h1:n2HQ6QxqyTySiSFTOpAL18SjCKtP+xUskMygO0KuuQU=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
Expand Down
Loading

0 comments on commit ba0abc5

Please sign in to comment.