Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Clivern committed Apr 6, 2024
1 parent 085bf62 commit 2412c5d
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 534 deletions.
21 changes: 0 additions & 21 deletions .copywrite.hcl

This file was deleted.

6 changes: 0 additions & 6 deletions GNUmakefile

This file was deleted.

396 changes: 21 additions & 375 deletions LICENSE

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
go ?= go
gofmt ?= $(go)fmt
pkgs = ./...


help: Makefile
@echo
@echo " Choose a command run in Lynx Terraform Provider:"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo


## install_revive: Install revive for linting.
.PHONY: install_revive
install_revive:
@echo ">> ============= Install Revive ============= <<"
$(go) install github.com/mgechev/revive@latest


## style: Check code style.
.PHONY: style
style:
@echo ">> ============= Checking Code Style ============= <<"
@fmtRes=$$($(gofmt) -d $$(find . -path ./vendor -prune -o -name '*.go' -print)); \
if [ -n "$${fmtRes}" ]; then \
echo "gofmt checking failed!"; echo "$${fmtRes}"; echo; \
echo "Please ensure you are using $$($(go) version) for formatting code."; \
exit 1; \
fi


## check_license: Check if license header on all files.
.PHONY: check_license
check_license:
@echo ">> ============= Checking License Header ============= <<"
@licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \
awk 'NR<=3' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \
done); \
if [ -n "$${licRes}" ]; then \
echo "license header checking failed:"; echo "$${licRes}"; \
exit 1; \
fi


## test_short: Run test cases with short flag.
.PHONY: test_short
test_short:
@echo ">> ============= Running Short Tests ============= <<"
$(go) clean -testcache
$(go) test -mod=readonly -short $(pkgs)


## test: Run test cases.
.PHONY: test
test:
@echo ">> ============= Running All Tests ============= <<"
$(go) clean -testcache
$(go) test -mod=readonly -run=Unit -bench=. -benchmem -v -cover $(pkgs)


## integration: Run integration test cases (Requires etcd)
.PHONY: integration
integration:
@echo ">> ============= Running All Tests ============= <<"
$(go) clean -testcache
$(go) test -mod=readonly -run=Integration -bench=. -benchmem -v -cover $(pkgs)


## lint: Lint the code.
.PHONY: lint
lint:
@echo ">> ============= Lint All Files ============= <<"
revive -config config.toml -exclude vendor/... -formatter friendly ./...


## verify: Verify dependencies
.PHONY: verify
verify:
@echo ">> ============= List Dependencies ============= <<"
$(go) list -m all
@echo ">> ============= Verify Dependencies ============= <<"
$(go) mod verify


## format: Format the code.
.PHONY: format
format:
@echo ">> ============= Formatting Code ============= <<"
$(go) fmt $(pkgs)


## vet: Examines source code and reports suspicious constructs.
.PHONY: vet
vet:
@echo ">> ============= Vetting Code ============= <<"
$(go) vet $(pkgs)


## coverage: Create HTML coverage report
.PHONY: coverage
coverage:
@echo ">> ============= Coverage ============= <<"
rm -f coverage.html cover.out
$(go) test -mod=readonly -coverprofile=cover.out $(pkgs)
go tool cover -html=cover.out -o coverage.html


## ci: Run all CI tests.
.PHONY: ci
ci: style check_license test vet lint
@echo "\n==> All quality checks passed"


.PHONY: help
30 changes: 0 additions & 30 deletions docs/data-sources/example.md

This file was deleted.

26 changes: 0 additions & 26 deletions docs/functions/example.md

This file was deleted.

26 changes: 0 additions & 26 deletions docs/index.md

This file was deleted.

31 changes: 0 additions & 31 deletions docs/resources/example.md

This file was deleted.

26 changes: 7 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,23 @@ import (
"github.com/clivern/terraform-provider-lynx/internal/provider"
)

// Run "go generate" to format example terraform files and generate the docs for the registry/website

// If you do not have terraform installed, you can remove the formatting command, but its suggested to
// ensure the documentation is formatted properly.
//go:generate terraform fmt -recursive ./examples/

// Run the docs generation tool, check its repository for more information on how it works and how docs
// can be customized.
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate -provider-name scaffolding

var (
// these will be set by the goreleaser configuration
// to appropriate values for the compiled binary.
version string = "dev"

// goreleaser can pass other information to the main package, such as the specific commit
// https://goreleaser.com/cookbooks/using-main.version/
)

func main() {
var debug bool

flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
flag.BoolVar(
&debug,
"debug",
false,
"set to true to run the provider with support for debuggers like delve",
)

flag.Parse()

opts := providerserver.ServeOpts{
// TODO: Update this string with the published name of your provider.
// Also update the tfplugindocs generate command to either remove the
// -provider-name flag or set its value to the updated provider name.
Address: "registry.terraform.io/clivern/lynx",
Debug: debug,
}
Expand Down

0 comments on commit 2412c5d

Please sign in to comment.