Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: inital implementation #2

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 20 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI
on:
push:
pull_request:

permissions:
contents: read

jobs:
build_test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Golang
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
- name: Make
run: make
22 changes: 22 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: golangci-lint
on:
push:
pull_request:

permissions:
contents: read
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
args: --timeout=5m
32 changes: 32 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: release
on:
push:
branches:
- master
tags:
- v*.*.*

permissions:
contents: write

jobs:
publish:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Setup Golang
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
- name: Go releaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
*.dll
*.exe
.DS_Store
example.tf
terraform.tfvars
terraform.tfplan
terraform.tfstate
bin/
modules-dev/
/pkg/
website/.vagrant
website/.bundle
website/build
website/node_modules
.vagrant/
*.backup
./*.tfstate
.terraform/
*.log
*.bak
*~
.*.swp
.idea
*.iml
*.test
*.iml
.vscode/

website/vendor

# Test exclusions
!command/test-fixtures/**/*.tfstate
!command/test-fixtures/**/.terraform/

dist/
61 changes: 61 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
run:
concurrency: 1
skip-dirs:
- vendor
timeout: 3m
modules-download-mode: vendor
allow-parallel-runners: false

linters:
enable:
- errcheck
- govet
- staticcheck
- typecheck
- unused
- vet
- stylecheck
- gocyclo
- gofmt
- gosimple
- ineffassign
- asciicheck
- bodyclose
- dogsled
- exportloopref
- gocognit
- gocritic
- godot
- godox
- goheader
- gomodguard
- goprintffuncname
- gosec
- lll
- misspell
- nakedret
- nestif
- noctx
- nolintlint
- prealloc
- unconvert
- unparam
- whitespace

linters-settings:
errcheck:
ignore: bytes:.*,io:Close|Write

lll:
line-length: 180

stylecheck:
pkg_name: false
camel_name: false

issues:
exclude-rules:
- path: _test\.go
linters:
- stylecheck
- unused
58 changes: 58 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
SHELL := /bin/bash

PROJECT_NAME := $(shell basename $(CURDIR))
empty:=
prefix:=terraform-provider-
PROVIDER_NAME := $(subst $(prefix),$(empty),$(PROJECT_NAME))

OS := $(shell go env GOHOSTOS)
ARCH := $(shell go env GOHOSTARCH)
LOCAL_PLUGIN_DIR := ~/.terraform.d/plugins/github.com/form3tech-oss/$(PROVIDER_NAME)/0.0.1/$(OS)_$(ARCH)


GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)

default: lint build test

test: fmtcheck
go test -v . ./chronicle

testacc: fmtcheck
TF_ACC=1 go test -v ./chronicle -timeout 120m -parallel 1

build:
@go build -mod=vendor -o $(PROJECT_NAME)
@echo "Build succeeded"

install: lint build
@mkdir -p $(LOCAL_PLUGIN_DIR)
@cp $(PROJECT_NAME) $(LOCAL_PLUGIN_DIR)/
@echo "Install succeeded"

clean:
go clean -testcache

fmt:
gofmt -w $(GOFMT_FILES)

fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v /vendor | grep -v /tools) ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi

lint: fmtcheck vet

docs:
tfplugindocs generate

vendor:
@go mod tidy && go mod vendor && go mod verify

.PHONY: build install lint test clean testacc vet fmt fmtcheck docs vendor
Loading
Loading