Skip to content

Commit c6be922

Browse files
Initial Version (#1)
1 parent 0b1d876 commit c6be922

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+9416
-0
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See GitHub's documentation for more information on this file:
2+
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
3+
version: 2
4+
updates:
5+
# Maintain dependencies for Go modules
6+
- package-ecosystem: "gomod"
7+
directory: "/"
8+
schedule:
9+
# Check for updates to Go modules every weekday
10+
interval: "daily"
11+
- package-ecosystem: "gomod"
12+
directory: "/tools"
13+
schedule:
14+
interval: "daily"
15+
- package-ecosystem: "github-actions"
16+
directory: "/"
17+
schedule:
18+
interval: "daily"

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
# Allow goreleaser to access older tag information.
23+
fetch-depth: 0
24+
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.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@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
36+
with:
37+
args: release --clean
38+
env:
39+
# GitHub sets the GITHUB_TOKEN secret automatically.
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.github/workflows/test.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Terraform Provider testing workflow.
2+
name: Tests
3+
4+
# This GitHub action runs your tests for each pull request and push.
5+
# Optionally, you can turn it on using a schedule for regular testing.
6+
on:
7+
pull_request:
8+
paths-ignore:
9+
- 'README.md'
10+
push:
11+
paths-ignore:
12+
- 'README.md'
13+
14+
# Testing only needs permissions to read the repository contents.
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
# Ensure project builds before running testing matrix
20+
build:
21+
name: Build
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 5
24+
steps:
25+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
27+
with:
28+
go-version-file: 'go.mod'
29+
cache: true
30+
- run: go mod download
31+
- run: go build -v .
32+
- name: Run linters
33+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
34+
with:
35+
version: latest
36+
37+
generate:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
41+
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
42+
with:
43+
go-version-file: 'go.mod'
44+
cache: true
45+
# We need the latest version of Terraform for our documentation generation to use
46+
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
47+
with:
48+
terraform_wrapper: false
49+
- run: make generate
50+
- name: git diff
51+
run: |
52+
git diff --compact-summary --exit-code || \
53+
(echo; echo "Unexpected difference in directories after code generation. Run 'make generate' command and commit."; exit 1)
54+
55+
# Run acceptance tests in a matrix with Terraform CLI versions
56+
test:
57+
name: Terraform Provider Acceptance Tests
58+
needs: build
59+
runs-on: ubuntu-latest
60+
timeout-minutes: 15
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
# list whatever Terraform versions here you would like to support
65+
terraform:
66+
- '1.0.*'
67+
- '1.1.*'
68+
- '1.2.*'
69+
- '1.3.*'
70+
- '1.4.*'
71+
steps:
72+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
73+
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
74+
with:
75+
go-version-file: 'go.mod'
76+
cache: true
77+
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
78+
with:
79+
terraform_version: ${{ matrix.terraform }}
80+
terraform_wrapper: false
81+
- run: go mod download
82+
- env:
83+
TF_ACC: "1"
84+
run: go test -v -cover ./internal/provider/
85+
timeout-minutes: 10

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
*.dll
2+
*.exe
3+
.DS_Store
4+
example.tf
5+
terraform.tfplan
6+
terraform.tfstate
7+
bin/
8+
dist/
9+
modules-dev/
10+
/pkg/
11+
website/.vagrant
12+
website/.bundle
13+
website/build
14+
website/node_modules
15+
.vagrant/
16+
*.backup
17+
./*.tfstate
18+
.terraform/
19+
*.log
20+
*.bak
21+
*~
22+
.*.swp
23+
.idea
24+
*.iml
25+
*.test
26+
*.iml
27+
28+
website/vendor
29+
30+
# Test exclusions
31+
!command/test-fixtures/**/*.tfstate
32+
!command/test-fixtures/**/.terraform/
33+
34+
# Keep windows files with windows line endings
35+
*.winfile eol=crlf

.golangci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright (c) HashiCorp, Inc.
2+
3+
version: "2"
4+
linters:
5+
default: none
6+
enable:
7+
- copyloopvar
8+
- durationcheck
9+
- errcheck
10+
- forcetypeassert
11+
- godot
12+
- ineffassign
13+
- makezero
14+
- misspell
15+
- nilerr
16+
- predeclared
17+
- staticcheck
18+
- unconvert
19+
- unparam
20+
- unused
21+
- usetesting
22+
exclusions:
23+
generated: lax
24+
presets:
25+
- comments
26+
- common-false-positives
27+
- legacy
28+
- std-error-handling
29+
paths:
30+
- third_party$
31+
- builtin$
32+
- examples$
33+
issues:
34+
max-issues-per-linter: 0
35+
max-same-issues: 0
36+
formatters:
37+
enable:
38+
- gofmt
39+
exclusions:
40+
generated: lax
41+
paths:
42+
- third_party$
43+
- builtin$
44+
- examples$

.goreleaser.yml

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

GNUmakefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
default: fmt lint install generate
2+
3+
build:
4+
go build -v ./...
5+
6+
install: build
7+
go install -v ./...
8+
9+
lint:
10+
golangci-lint run
11+
12+
generate:
13+
cd tools; go generate ./...
14+
15+
fmt:
16+
gofmt -s -w -e .
17+
18+
test:
19+
go test -v -cover -timeout=120s -parallel=10 ./...
20+
21+
testacc:
22+
TF_ACC=1 go test -v -cover -timeout 120m ./...
23+
24+
.PHONY: fmt lint test testacc build install generate

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# NetBird Terraform Provider
2+
3+
A Terraform Provider for managing your [NetBird](https://netbird.io) Account and its resources.
4+
5+
## Requirements
6+
7+
- [Terraform](https://developer.hashicorp.com/terraform/downloads) >= 1.0
8+
- [Go](https://golang.org/doc/install) >= 1.23
9+
- [NetBird Account](https://docs.netbird.io/)
10+
11+
## Building The Provider
12+
13+
1. Clone the repository
14+
1. Enter the repository directory
15+
1. Build the provider using the Go `install` command:
16+
17+
```shell
18+
go install
19+
```
20+
21+
## Adding Dependencies
22+
23+
This provider uses [Go modules](https://github.com/golang/go/wiki/Modules).
24+
Please see the Go documentation for the most up to date information about using Go modules.
25+
26+
To add a new dependency `github.com/author/dependency` to your Terraform provider:
27+
28+
```shell
29+
go get github.com/author/dependency
30+
go mod tidy
31+
```
32+
33+
Then commit the changes to `go.mod` and `go.sum`.
34+
35+
## Using the provider
36+
37+
Check usage in [docs](./docs/index.md).
38+
39+
## Developing the Provider
40+
41+
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).
42+
43+
To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
44+
45+
To generate or update documentation, run `make generate`.
46+
47+
In order to run the full suite of Acceptance tests, run `make testacc`.
48+
49+
*Note:* Acceptance tests create real resources, and often cost money to run.
50+
51+
```shell
52+
make testacc
53+
```

0 commit comments

Comments
 (0)