Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vandyliu committed Apr 10, 2024
1 parent a21650c commit 7f79d86
Show file tree
Hide file tree
Showing 30 changed files with 1,301 additions and 464 deletions.
32 changes: 2 additions & 30 deletions .github/workflows/test.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Terraform Provider testing workflow.
name: Tests
name: Build

# This GitHub action runs your tests for each pull request and push.
# Optionally, you can turn it on using a schedule for regular testing.
Expand Down Expand Up @@ -63,32 +63,4 @@ jobs:
- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
# Run acceptance tests in a matrix with Terraform CLI versions
test:
name: Terraform Provider Acceptance Tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- '1.0.*'
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- env:
TF_ACC: "1"
run: go test -v -cover ./internal/provider/
timeout-minutes: 10
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
98 changes: 98 additions & 0 deletions .github/workflows/testacc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Terraform Provider testing workflow.
name: Build

# This GitHub action runs your tests for each pull request and push.
# Optionally, you can turn it on using a schedule for regular testing.
on:
issue_comment:
types: [created]
paths-ignore:
- 'README.md'
push:
branches:
- main
paths-ignore:
- 'README.md'

# Testing only needs permissions to read the repository contents.
permissions:
contents: read

jobs:
build:
if: github.event.issue.pull_request && contains(github.event.comment.body, '/run-testacc')
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go build -v .

comment-triggered-testacc:
# This job runs on issue_comment event with /run-testacc command.
# We will block merging to main unless this job passes
# The reason we don't want to run this on every push is because it's expensive/creates real resources
if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/run-testacc') }}
name: Terraform Provider Acceptance Tests
needs: build
runs-on: ubuntu-latest
environment: dev
timeout-minutes: 15
strategy:
fail-fast: true
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- '1.7.*'
- '1.6.*'
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- env:
TF_ACC: "1"
run: make testacc
timeout-minutes: 10

main-testacc:
# This job runs on push to main branch.
if: ${{ github.event_name == 'push' }}
name: Terraform Provider Acceptance Tests
needs: build
environment: dev
timeout-minutes: 15
strategy:
fail-fast: true
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- '1.7.*'
- '1.6.*'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- env:
TF_ACC: "1"
run: make testacc
timeout-minutes: 10
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ OAPI_CODEGEN ?= $(ENVTEST_ASSETS_DIR)/oapi-codegen
# Run acceptance tests
.PHONY: testacc
testacc:
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m
TF_ACC=1 go test ./... -v -run TestAcc $(TESTARGS) -timeout 120m

# Run unit tests
.PHONY: test
test:
go vet ./...
go run github.com/onsi/ginkgo/v2/ginkgo run -r -v --cover --covermode atomic --junit-report=report.xml --output-dir=test_results $(ARGS)
TF_ACC="" go test ./... -v $(TESTARGS)

.PHONY: fmt
fmt:
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,15 @@ output "terraform_workspace" {
```

## Testing
TODO: In order to run the full suite of Acceptance tests, run `make testacc`.
Unit tests can be run with `make test`.

*Note:* Acceptance tests create real resources, and often cost money to run.
In order to run the full suite of Acceptance tests, run `make testacc`.
You will also need to set the following environment variables:
- `ASTRO_API_HOST`
- `ASTRO_API_TOKEN`
- `ASTRO_ORGANIZATION_ID`

The acceptance tests will run against the Astronomer API and create/read/update/delete real resources.



50 changes: 50 additions & 0 deletions docs/data-sources/organization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "astronomer_organization Data Source - astronomer"
subcategory: ""
description: |-
Organization data source
---

# astronomer_organization (Data Source)

Organization data source



<!-- schema generated by tfplugindocs -->
## Schema

### Read-Only

- `created_at` (String) Organization creation timestamp
- `created_by` (Attributes) Organization creator (see [below for nested schema](#nestedatt--created_by))
- `id` (String) Organization identifier
- `name` (String) Organization name
- `updated_at` (String) Organization last updated timestamp
- `updated_by` (Attributes) Organization updater (see [below for nested schema](#nestedatt--updated_by))

<a id="nestedatt--created_by"></a>
### Nested Schema for `created_by`

Read-Only:

- `api_token_name` (String)
- `avatar_url` (String)
- `full_name` (String)
- `id` (String)
- `subject_type` (String)
- `username` (String)


<a id="nestedatt--updated_by"></a>
### Nested Schema for `updated_by`

Read-Only:

- `api_token_name` (String)
- `avatar_url` (String)
- `full_name` (String)
- `id` (String)
- `subject_type` (String)
- `username` (String)
18 changes: 13 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ require (
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/hashicorp/terraform-plugin-go v0.22.1
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-testing v1.7.0
github.com/lucsky/cuid v1.2.1
github.com/oapi-codegen/runtime v1.1.1
github.com/onsi/ginkgo/v2 v2.17.1
github.com/onsi/gomega v1.32.0
github.com/samber/lo v1.39.0
github.com/stretchr/testify v1.9.0
)

require (
Expand All @@ -21,30 +21,33 @@ require (
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/cli v1.1.6 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.6.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.6.3 // indirect
github.com/hashicorp/hcl/v2 v2.20.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.20.0 // indirect
github.com/hashicorp/terraform-json v0.21.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
Expand All @@ -55,14 +58,18 @@ require (
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yuin/goldmark v1.6.0 // indirect
Expand All @@ -75,6 +82,7 @@ require (
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.17.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
Expand Down
Loading

0 comments on commit 7f79d86

Please sign in to comment.