Skip to content

Commit f10103d

Browse files
authored
New Terraform Provider for Hatchet Cloud (#1)
* provider base interface * add license and goreleaser * more tf related files and workflows * resources and data-sources with examples * run fmt * get org id and server url from token itself * hatchet_user data source * update examples * fixes for testing * all tests done * first version * update provider name to hatchet * use tf conventions * tiny fix * org member resource * edge cases for org member * fix example * fix generate * make generate * update docs * fix docs
1 parent 1e34d6c commit f10103d

35 files changed

+4963
-1
lines changed

.copywrite.hcl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
schema_version = 1
2+
3+
project {
4+
license = "MIT"
5+
copyright_holder = "Hatchet Technologies Inc."
6+
copyright_year = 2025
7+
8+
header_ignore = [
9+
# internal catalog metadata (prose)
10+
"META.d/**/*.yaml",
11+
12+
# examples used within documentation (prose)
13+
"examples/**",
14+
15+
# GitHub issue template configuration
16+
".github/ISSUE_TEMPLATE/*.yml",
17+
18+
# golangci-lint tooling configuration
19+
".golangci.yml",
20+
21+
# GoReleaser tooling configuration
22+
".goreleaser.yml",
23+
]
24+
}

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
8+
- package-ecosystem: "gomod"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"

.github/pull_request_template.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Description
2+
3+
<!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. -->
4+
5+
Fixes # (issue)
6+
7+
## Type of change
8+
9+
<!-- Please delete options that are not relevant. -->
10+
11+
- [ ] Bug fix (non-breaking change which fixes an issue)
12+
- [ ] Documentation change (pure documentation change)
13+
- [ ] New feature (non-breaking change which adds functionality)
14+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
15+
- [ ] Refactor (non-breaking changes to code which doesn't change any behaviour)
16+
- [ ] CI (any automation pipeline changes)
17+
- [ ] Chore (changes which are not directly related to any business logic)
18+
- [ ] Test changes (add, refactor, improve or change a test)
19+
- [ ] This change requires a documentation update
20+
21+
## What's Changed
22+
23+
- [ ] Add a list of tasks or features here...

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Terraform Provider release workflow.
2+
name: Release
3+
4+
# This GitHub action creates a release when a tag that matches the pattern
5+
# "v*" (e.g. v0.1.0) is created.
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
# Releases need permissions to read and write the repository contents.
12+
# GitHub considers creating releases and uploading assets as writing contents.
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
goreleaser:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
21+
with:
22+
# Allow goreleaser to access older tag information.
23+
fetch-depth: 0
24+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
25+
with:
26+
go-version-file: 'go.mod'
27+
cache: true
28+
- name: Import GPG key
29+
uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0
30+
id: import_gpg
31+
with:
32+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
33+
passphrase: ${{ secrets.PASSPHRASE }}
34+
- name: Run GoReleaser
35+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
36+
with:
37+
args: release --clean
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*.dll
55
*.so
66
*.dylib
7-
terraform-provider-hatchetcloud
7+
terraform-provider-hatchet
88

99
# Test binary, built with `go test -c`
1010
*.test
@@ -44,3 +44,6 @@ dist/
4444
.Trashes
4545
ehthumbs.db
4646
Thumbs.db
47+
48+
# Project specific files
49+
bin

.goreleaser.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
version: 2
2+
project_name: hatchet
3+
before:
4+
hooks:
5+
- go mod tidy
6+
builds:
7+
- env:
8+
# goreleaser does not work with CGO, it could also complicate
9+
# usage by users in CI/CD systems like HCP Terraform where
10+
# they are unable to install libraries.
11+
- CGO_ENABLED=0
12+
mod_timestamp: '{{ .CommitTimestamp }}'
13+
flags:
14+
- -trimpath
15+
ldflags:
16+
- '-s -w -X main.version={{.Version}}'
17+
goos:
18+
- freebsd
19+
- windows
20+
- linux
21+
- darwin
22+
goarch:
23+
- amd64
24+
- '386'
25+
- arm
26+
- arm64
27+
ignore:
28+
- goos: darwin
29+
goarch: '386'
30+
binary: '{{ .ProjectName }}_v{{ .Version }}'
31+
archives:
32+
- format: zip
33+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
34+
checksum:
35+
extra_files:
36+
- glob: 'terraform-registry-manifest.json'
37+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
38+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
39+
algorithm: sha256
40+
signs:
41+
- artifacts: checksum
42+
args:
43+
# if you are using this in a GitHub action or some other automated pipeline, you
44+
# need to pass the batch flag to indicate its not interactive.
45+
- "--batch"
46+
- "--local-user"
47+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
48+
- "--output"
49+
- "${signature}"
50+
- "--detach-sign"
51+
- "${artifact}"
52+
release:
53+
extra_files:
54+
- glob: 'terraform-registry-manifest.json'
55+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
56+
# If you want to manually examine the release before its live, uncomment this line:
57+
# draft: true
58+
changelog:
59+
disable: true

GNUmakefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
default: fmt lint install generate
2+
3+
build:
4+
go build -o terraform-provider-hatchet
5+
6+
install: build
7+
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/hatchet-dev/hatchet/0.1.0/darwin_arm64
8+
mv terraform-provider-hatchet ~/.terraform.d/plugins/registry.terraform.io/hatchet-dev/hatchet/0.1.0/darwin_arm64/terraform-provider-hatchet
9+
lint:
10+
golangci-lint run
11+
12+
generate:
13+
cd tools; go generate ./...
14+
15+
fmt:
16+
gofumpt -l -w .
17+
terraform fmt -recursive .
18+
19+
test:
20+
go test -v -cover -timeout=120s -parallel=10 ./...
21+
22+
testacc:
23+
TF_ACC=1 go test -v -cover -timeout 120m ./...
24+
25+
.PHONY: fmt lint test testacc build install generate

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025-present Hatchet Technologies Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,100 @@
11
# Terraform Provider for Hatchet Cloud
2+
3+
A Terraform provider for managing Hatchet Cloud resources.
4+
5+
## Requirements
6+
7+
- [Terraform](https://www.terraform.io/downloads.html) >= 1.0
8+
- [Go](https://golang.org/doc/install) >= 1.25
9+
10+
## Building The Provider
11+
12+
1. Clone the repository
13+
2. Enter the repository directory
14+
3. Build the provider using the Go `go build` command:
15+
16+
```shell
17+
go build -o terraform-provider-hatchet
18+
```
19+
20+
## Installing the Provider
21+
22+
### Local Installation
23+
24+
To install the provider locally for development:
25+
26+
```shell
27+
make install
28+
```
29+
30+
This will build the provider and install it in the correct location for Terraform to find it.
31+
32+
### Using the Provider
33+
34+
Create a Terraform configuration file (e.g., `main.tf`) with the following content:
35+
36+
```hcl
37+
terraform {
38+
required_providers {
39+
hatchet = {
40+
source = "hatchet-dev/hatchet"
41+
version = "~> 1.0"
42+
}
43+
}
44+
}
45+
46+
provider "hatchet" {
47+
# optionally can set the "token" but for production environments please use the HATCHET_CLOUD_MANAGEMENT_TOKEN environment variable
48+
}
49+
```
50+
51+
You can also use environment variables for configuration:
52+
53+
```bash
54+
export HATCHET_CLOUD_MANAGEMENT_TOKEN="your-api-token-here"
55+
```
56+
57+
## Development
58+
59+
### Running Tests
60+
61+
```shell
62+
make test
63+
```
64+
65+
### Formatting Code
66+
67+
```shell
68+
make fmt
69+
```
70+
71+
### Generating Documentation
72+
73+
```shell
74+
make docs
75+
```
76+
77+
### Cleaning Build Artifacts
78+
79+
```shell
80+
make clean
81+
```
82+
83+
## Provider Configuration
84+
85+
The Hatchet Cloud provider supports the following configuration options:
86+
87+
- `token` (Sensitive): Your Hatchet Cloud API token for authentication. Can also be set via the `HATCHET_CLOUD_MANAGEMENT_TOKEN` environment variable.
88+
89+
## Contributing
90+
91+
1. Fork the repository
92+
2. Create a feature branch
93+
3. Make your changes
94+
4. Add tests for your changes
95+
5. Run the test suite
96+
6. Submit a pull request
97+
98+
## License
99+
100+
This project is licensed under the MIT License.

docs/data-sources/organization.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "hatchet_organization Data Source - Hatchet"
4+
subcategory: ""
5+
description: |-
6+
Fetches information about a Hatchet organization.
7+
---
8+
9+
# hatchet_organization (Data Source)
10+
11+
Fetches information about a Hatchet organization.
12+
13+
## Example Usage
14+
15+
```terraform
16+
terraform {
17+
required_providers {
18+
hatchet = {
19+
source = "hatchet-dev/hatchet"
20+
version = "~> 0.1.0"
21+
}
22+
}
23+
}
24+
25+
provider "hatchet" {
26+
# Token is read from HATCHET_CLOUD_MANAGEMENT_TOKEN environment variable
27+
}
28+
29+
# Fetch organization information by ID
30+
data "hatchet_organization" "example" {
31+
id = "17015348-d740-45f2-b23d-ea284c6eb3ee"
32+
}
33+
```
34+
35+
<!-- schema generated by tfplugindocs -->
36+
## Schema
37+
38+
### Required
39+
40+
- `id` (String) The ID of the organization.
41+
42+
### Read-Only
43+
44+
- `name` (String) The name of the organization.

0 commit comments

Comments
 (0)