Skip to content

Commit

Permalink
Add airflow_user Resource (#7)
Browse files Browse the repository at this point in the history
* add user resource

* generate docs

* add acceptance tests
  • Loading branch information
ajbosco authored Dec 3, 2021
1 parent 2857916 commit e442b48
Show file tree
Hide file tree
Showing 22 changed files with 794 additions and 147 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
go: [ '1.14' ]
go: [ '1.17' ]
steps:
- uses: actions/checkout@v2
- name: Setup go
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.14
go-version: 1.17
id: go

- name: Run goreleaser
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your
# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
Expand All @@ -30,7 +30,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.17
-
name: Import GPG key
id: import_gpg
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ terraform-provider-airflow
terraform.tfstate
terraform.tfstate.*
.terraform
vendor
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
build:
go build -o terraform-provider-airflow

docs:
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs

vendor:
go mod vendor
go mod tidy

test-acceptance:
@AIRFLOW_API_USERNAME=airflow \
AIRFLOW_API_PASSWORD=airflow \
AIRFLOW_BASE_ENDPOINT=http://127.0.0.1:8080 \
TF_ACC=1 $(go_test) go test -v -cover $(shell go list ./... | grep -v vendor)

start-airflow:
docker run -d -e AIRFLOW__API__AUTH_BACKEND=airflow.api.auth.backend.basic_auth \
-p 127.0.0.1:8080:8080 --name=airflow apache/airflow:2.2.2 standalone

stop-airflow:
docker stop airflow; docker rm airflow
8 changes: 8 additions & 0 deletions docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build tools
// +build tools

package docs

import (
_ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs"
)
27 changes: 27 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
page_title: "Provider: Airflow"
description: Manage Airflow with Terraform.
---

# Airflow Provider

This is a terraform provider plugin for managing [Apache Airflow](https://airflow.apache.org/).

## Example Provider Configuration

```terraform
terraform {
required_providers {
airflow = {
source = "houqp/airflow"
version = "0.2.1"
}
}
}
provider "airflow" {
base_endpoint = "http://localhost:28080/"
username = "test"
password = "test"
}
```
40 changes: 40 additions & 0 deletions docs/resources/user.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "airflow_user Resource - terraform-provider-airflow"
subcategory: ""
description: |-
---

# airflow_user (Resource)



## Example Usage

```terraform
resource "airflow_user" "example_user" {
username = "test_user"
email = "[email protected]"
first_name = "test"
last_name = "user"
}
```

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

### Required

- **email** (String)
- **first_name** (String)
- **last_name** (String)
- **username** (String)

### Optional

- **id** (String) The ID of this resource.
- **password** (String, Sensitive) **WARNING:** this will put the password in the terraform state file. Use carefully.
- **roles** (Set of String)


39 changes: 39 additions & 0 deletions docs/resources/variable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "airflow_variable Resource - terraform-provider-airflow"
subcategory: ""
description: |-
---

# airflow_variable (Resource)



## Example Usage

```terraform
resource "airflow_variable" "foo" {
key = "foo"
value = "bar"
}
resource "airflow_variable" "hello" {
key = "hello"
value = "world"
}
```

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

### Required

- **key** (String)
- **value** (String)

### Optional

- **id** (String) The ID of this resource.


10 changes: 0 additions & 10 deletions examples/variable/demo.tf → examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,3 @@ provider "airflow" {
username = "test"
password = "test"
}

resource "airflow_variable" "foo" {
key = "foo"
value = "bar"
}

resource "airflow_variable" "hello" {
key = "hello"
value = "world"
}
6 changes: 6 additions & 0 deletions examples/resources/airflow_user/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "airflow_user" "example_user" {
username = "test_user"
email = "[email protected]"
first_name = "test"
last_name = "user"
}
9 changes: 9 additions & 0 deletions examples/resources/airflow_variable/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "airflow_variable" "foo" {
key = "foo"
value = "bar"
}

resource "airflow_variable" "hello" {
key = "hello"
value = "world"
}
84 changes: 79 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,84 @@
module github.com/apache/terraform-provider-airflow

go 1.13
go 1.17

require (
github.com/apache/airflow-client-go/airflow v0.0.0-20200906053102-e1deffdac652
github.com/hashicorp/terraform-plugin-sdk v1.10.0
golang.org/x/net v0.0.0-20200904194848-62affa334b73 // indirect
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect
github.com/apache/airflow-client-go/airflow v0.0.0-20211202191715-b125451e80fd
github.com/hashicorp/terraform-plugin-docs v0.5.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.9.0
)

require (
cloud.google.com/go v0.65.0 // indirect
cloud.google.com/go/storage v1.10.0 // indirect
github.com/Masterminds/goutils v1.1.0 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-cidr v1.0.1 // indirect
github.com/apparentlymart/go-textseg v1.0.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 // indirect
github.com/aws/aws-sdk-go v1.25.3 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
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-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-getter v1.5.3 // indirect
github.com/hashicorp/go-hclog v0.15.0 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/go-plugin v1.4.1 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-uuid v1.0.1 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hashicorp/hcl/v2 v2.3.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.15.0 // indirect
github.com/hashicorp/terraform-json v0.13.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.4.0 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/klauspost/compress v1.11.2 // indirect
github.com/mattn/go-colorable v0.1.11 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/cli v1.1.2 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.4 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/posener/complete v1.1.1 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/zclconf/go-cty v1.10.0 // indirect
go.opencensus.io v0.22.4 // indirect
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
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-20210218202405-ba52d332ba99 // indirect
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.30.0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987 // indirect
google.golang.org/grpc v1.32.0 // indirect
google.golang.org/protobuf v1.25.0 // indirect
)
Loading

0 comments on commit e442b48

Please sign in to comment.