Skip to content

Commit

Permalink
Initial provider (#1)
Browse files Browse the repository at this point in the history
* initial port from poc repo

* spelling

* check applied resource's status because we cannot rely on status

* Remove unused conversion function

* move retry function

* make destinations generic

* rename resource_configuration.go

* rename raw configuration resource to configuration

* WIP: begin implementing sources and destinations on configs

* update hashicorp sdk

* turn off list value for now

* use jsonencode for params, work in progress

* fix sources and destinations

* move raw config back to its own resource type

* WIP: move sources to their own resource

* handle auto rollout

* fix broken tests. rollout on new creation

* add platform option

* fix match labels but computing them and restricting them to configuration=<config name>. re-added inline source (WIP) and kept it commented for now

* merge code that is only used in one place

* switch back to line sources

* rename inline source block to 'source'

* change parameters_json syntax so we can marshal and unmarshal directly without conversion logic

* support embeded and source by name

* handle marshal and unmarhsal of params in parameter package

* re-enable parameter package tests

* add processor resource

* convert destinations list to block

* support attaching processors to destinations

* merge source and sources option, supporting both embeded and by name sources

* remove inline / embeded sources

* Refactor resource handling for source and destination

* only rollout configs

* sync tests

* remove docker build from integration tests

* fix error handling in order to detect failures

* sync tests

* replace depricated github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource with github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry

* resolve linter checks

* add tests

* remove retry logic from provider package, as we only retry in situations where bindplane might have network issues. added some retry logic to internal/client apply

* refactor resource creation by moving logic to AnyResourceV1

* fix function rename

* Refactor provider for code re-use

* additional refactor

* move map to maputil package

* linter fixes

* dont sign when building locally

* new gpg key

* ci workflows

* fix go version

* fix directory path

* fix ci?

* update env variable prefix

* remove prompt

* add gpg fingerprint

* allow Unicode-DFS-2016

* add ability to set a profile

* add startup healthcheck to fail early when bindplane is not available, instead of failing every request

* undo healthcheck

* start adding param descriptions

* remove computed version, we don't use it

* finish descriptions for resource params

* update provider config doc

* rename serverURL and add profile env

* begin resource docs

* Add todo bindplane_configuration doc so we can link to it

* fix param type

* show example usage after apply

* omit command

* Add destination doc

* Add processor doc

* add configuration doc

* move raw config doc

* update raw config doc with latest options

* remove profile support, for now (#2)

* expose client package so it can be imported by the enterprise provider (#3)

* use errors.Join instead of multierror

* replace context TODO w/ background

* use %w when wrapping error with fmt.Errorf

* rename ProviderWithSchema to Configure to prevent package / function name stutter

* use bindplane 1.21.0 and collector 1.29.1

* use go 1.20.5

* remove dev from ci on push [skip-ci]
  • Loading branch information
jsirianni authored Jul 26, 2023
1 parent 2253e20 commit 2a95eb3
Show file tree
Hide file tree
Showing 46 changed files with 6,373 additions and 0 deletions.
231 changes: 231 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main

concurrency:
group: ${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

jobs:
setup-environment:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v2.1.4
with:
go-version: "1.20.5"

- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tooling-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}

- name: Install Tools
if: steps.tool-cache.outputs.cache-hit != 'true'
run: make install-tools

vet:
runs-on: "ubuntu-22.04"
needs:
- setup-environment
steps:
- name: Check out source code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20.5"

- name: Vet
run: go vet ./...

secure:
runs-on: "ubuntu-22.04"
needs:
- setup-environment
steps:
- name: Check out source code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20.5"

- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tooling-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}

- name: Gosec
run: make gosec

check-license:
runs-on: "ubuntu-22.04"
needs:
- setup-environment
steps:

- name: Check out source code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20.5"

- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tooling-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}

- name: Check License Headers
run: make check-license

lint:
runs-on: "ubuntu-22.04"
needs:
- setup-environment
steps:
- name: Check out source code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20.5"

- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tooling-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}

- name: Lint
run: make lint

check-fmt:
runs-on: "ubuntu-22.04"
needs:
- setup-environment
steps:
- name: Check out source code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20.5"

- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tooling-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}

- name: Check Format
run: make check-fmt

misspell:
runs-on: "ubuntu-22.04"
needs:
- setup-environment
steps:
- name: Check out source code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20.5"

- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tooling-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}

- name: Misspell
run: make misspell

test-end-to-end:
runs-on: "ubuntu-22.04"
needs:
- setup-environment
steps:
- name: Check out source code
uses: actions/checkout@v3

- uses: KengoTODA/actions-setup-docker-compose@main
with:
version: '2.7.0'

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20.5"

- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tooling-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}

- run: make test-end-to-end

build:
runs-on: "ubuntu-22.04"
needs:
- setup-environment
steps:
- name: Check out source code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20.5"

- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tooling-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}

- name: Import GPG key
id: import_gpg
uses: paultyng/ghaction-import-gpg@v2.1.0
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}

- name: Test GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --skip-publish --rm-dist --parallelism 2 --config release/goreleaser.yml
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

- name: Scan Binaries
run: lichen --config=./license.yaml $(find dist/provider_* -type f | grep terraform-provider-bindplane | xargs)
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: release
on:
push:
tags:
- 'v*'
jobs:
goreleaser:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Unshallow
run: git fetch --prune --unshallow

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.20.5"

- name: Import GPG key
id: import_gpg
uses: paultyng/ghaction-import-gpg@v2.1.0
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist --config release/goreleaser.yml
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

**/terraform-provider-bindplane*
dist/

cover.out

client/tls
30 changes: 30 additions & 0 deletions .revive.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 1
warningCode = 1

[rule.blank-imports]
[rule.context-as-argument]
[rule.context-keys-type]
[rule.dot-imports]
[rule.error-return]
[rule.error-strings]
[rule.error-naming]
[rule.exported]
[rule.if-return]
[rule.increment-decrement]
[rule.var-naming]
[rule.var-declaration]
[rule.package-comments]
[rule.range]
[rule.receiver-naming]
[rule.time-naming]
[rule.unexported-return]
[rule.indent-error-flow]
[rule.errorf]
[rule.empty-block]
[rule.superfluous-else]
[rule.unused-parameter]
[rule.unreachable-code]
[rule.redefines-builtin-id]
Loading

0 comments on commit 2a95eb3

Please sign in to comment.