Skip to content

Commit

Permalink
Add deployment resource (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
vandyliu authored Apr 17, 2024
1 parent bde8d98 commit ef74459
Show file tree
Hide file tree
Showing 48 changed files with 3,369 additions and 482 deletions.
20 changes: 19 additions & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
set -e

echo "Running pre-commit hook"
make fmt
make build
go generate ./...
# Add examples and docs files to git after documentation is generated
git add examples/
git add docs/

# First, get a list of all staged go files (ends in .go)
gofiles="$(git diff --cached --name-only --diff-filter=ACM --line-prefix="$(git rev-parse --show-toplevel)"/ '*.go')"
[ -z "$gofiles" ] && exit 0

for file in $gofiles; do
echo "running pre commit hook on $file"
# format the file
gofmt -w "$file"

# run goimports
goimports -w "$file"

# add the new changes to git commit
git add $file
done

echo "Pre-commit hook finished"
2 changes: 0 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

## 🎟 Issue(s)

Related #XXX

## 🧪 Functional Testing

<!--- List the functional testing steps to confirm this feature or fix. --->
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/testacc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ jobs:
- run: go mod download
- env:
TF_ACC: "1"
ASTRO_API_TOKEN: ${{ secrets.DEV_ASTRO_API_TOKEN }}
ASTRO_ORGANIZATION_ID: ckmzjm22937931d35puw3tcdo
HYBRID_ORGANIZATION_API_TOKEN: ${{ secrets.DEV_HYBRID_ORGANIZATION_API_TOKEN }}
HYBRID_ORGANIZATION_ID: ckmzjm22937931d35puw3tcdo
HOSTED_ORGANIZATION_API_TOKEN: ${{ secrets.DEV_HOSTED_ORGANIZATION_API_TOKEN }}
HOSTED_ORGANIZATION_ID: clczfgzc3001o01kjlphpi6hv
HYBRID_CLUSTER_ID: clnp86ly5000401ndagu20g81
HYBRID_NODE_POOL_ID: clnp86ly5000301ndzfxz895w
ASTRO_API_HOST: https://api.astronomer-dev.io
TESTARGS: "-failfast"
run: make testacc
timeout-minutes: 10

22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ provider "astronomer" {
3. Run the following commands to apply the provider:
```shell
export ASTRO_API_TOKEN=<token>
terraform apply
terraform plan
terraform init # only needed the first time - initializes a working directory and downloads the necessary provider plugins and modules and setting up the backend for storing your infrastructure's state
terraform plan # creates a plan consisting of a set of changes that will make your resources match your configuration
terraform apply # performs a plan just like terraform plan does, but then actually carries out the planned changes to each resource using the relevant infrastructure provider's API
```

## Developing the Provider
Expand All @@ -63,16 +64,16 @@ If you wish to work on the provider, you'll first need [Go](http://www.golang.or

To compile the provider, see [Building The Provider](## Building The Provider).

To add example docs, add the correspond `.tf` files to the `examples` directory.
To add example docs, add the correspond `.tf` files to the `examples` directory. These should be added for every new data source and resource.

To run terraform with the provider, create a `.terraformrc` file in your home directory (`~`) with the following content to override the provider installation with the local build:

```hcl
provider_installation {
dev_overrides {
"registry.terraform.io/astronomer/astronomer" = "~/astronomer/astronomer-terraform-provider/bin" # Path to the provider binary
"registry.terraform.io/astronomer/astronomer" = "~/astronomer-terraform-provider/bin" # Your path to the provider binary
}
direct {}
direct {}
}
```

Expand All @@ -86,14 +87,9 @@ terraform {
}
}
variable "token" {
type = string
}
provider "astronomer" {
organization_id = "<cuid>"
host = "https://api.astronomer-dev.io"
token = var.token
}
data "astronomer_workspace" "example" {
Expand Down Expand Up @@ -131,8 +127,10 @@ Using the terraform-plugin-testing framework, each `resource.Test` runs an accep
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`
- `HOSTED_ORGANIZATION_ID`
- `HOSTED_ORGANIZATION_API_TOKEN` - an organization owner API token for the above organization
- `HYBRID_ORGANIZATION_ID`
- `HYBRID_ORGANIZATION_API_TOKEN` - an organization owner API token for the above organization

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

Expand Down
3 changes: 0 additions & 3 deletions docs/data-sources/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ data "astronomer_deployment" "example" {
- `updated_at` (String) Deployment last updated timestamp
- `updated_by` (Attributes) Deployment updater (see [below for nested schema](#nestedatt--updated_by))
- `webserver_airflow_api_url` (String) Deployment webserver Airflow API URL
- `webserver_cpu` (String) Deployment webserver CPU
- `webserver_ingress_hostname` (String) Deployment webserver ingress hostname
- `webserver_memory` (String) Deployment webserver memory
- `webserver_replicas` (Number) Deployment webserver replicas
- `webserver_url` (String) Deployment webserver URL
- `worker_queues` (Attributes List) Deployment worker queues (see [below for nested schema](#nestedatt--worker_queues))
- `workload_identity` (String) Deployment workload identity
Expand Down
3 changes: 0 additions & 3 deletions docs/data-sources/deployments.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ Read-Only:
- `updated_at` (String) Deployment last updated timestamp
- `updated_by` (Attributes) Deployment updater (see [below for nested schema](#nestedatt--deployments--updated_by))
- `webserver_airflow_api_url` (String) Deployment webserver Airflow API URL
- `webserver_cpu` (String) Deployment webserver CPU
- `webserver_ingress_hostname` (String) Deployment webserver ingress hostname
- `webserver_memory` (String) Deployment webserver memory
- `webserver_replicas` (Number) Deployment webserver replicas
- `webserver_url` (String) Deployment webserver URL
- `worker_queues` (Attributes List) Deployment worker queues (see [below for nested schema](#nestedatt--deployments--worker_queues))
- `workload_identity` (String) Deployment workload identity
Expand Down
4 changes: 4 additions & 0 deletions docs/data-sources/organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ description: |-

Organization data source

## Example Usage

```terraform
data "astronomer_organization" "example" {}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
Loading

0 comments on commit ef74459

Please sign in to comment.