mirror of
https://github.com/wahyd4/terraform-provider-confluentcloud.git
synced 2026-08-09 04:25:51 +10:00
Merge pull request #2 from cgroschupp/feat/gh-actions
add github actions pipeline
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# http://editorconfig.org
|
||||
|
||||
# this file is the top-most editorconfig file
|
||||
root = true
|
||||
|
||||
# all files
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.go]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
[json*.golden]
|
||||
insert_final_newline = false
|
||||
|
||||
[*.{yaml,yml}]
|
||||
indent_size = 2
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
@@ -0,0 +1,43 @@
|
||||
name: build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Go 1.12
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.12
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v1
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
- name: Run tests
|
||||
run: make test
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Go 1.12
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.12
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Build binary for current OS/ARCH
|
||||
run: make build
|
||||
@@ -0,0 +1,38 @@
|
||||
name: prerelease
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
jobs:
|
||||
prerelease:
|
||||
name: Pre-Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Go 1.12
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.12
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v1
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
- name: Build binaries for all OS/ARCH platforms
|
||||
run: |
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
make gox build-all
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: bin/terraform-provider-confluentcloud-v*
|
||||
draft: false
|
||||
prerelease: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,2 +1,3 @@
|
||||
!/examples/main.tf
|
||||
/examples/*
|
||||
bin
|
||||
|
||||
+72
-7
@@ -1,15 +1,80 @@
|
||||
TEST?=./...
|
||||
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
|
||||
|
||||
default: build
|
||||
# Project variables
|
||||
NAME := terraform-provider-confluentcloud
|
||||
# Build variables
|
||||
BUILD_DIR := bin
|
||||
VERSION ?= $(shell git describe --tags --exact-match 2>/dev/null || git describe --tags 2>/dev/null || echo "v0.0.0-$(COMMIT_HASH)")
|
||||
# Go variables
|
||||
GOCMD := GO111MODULE=on go
|
||||
GOBUILD ?= CGO_ENABLED=0 $(GOCMD) build
|
||||
GOOS ?= $(shell go env GOOS)
|
||||
GOARCH ?= $(shell go env GOARCH)
|
||||
GOFILES ?= $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
|
||||
build:
|
||||
go install
|
||||
.PHONY: all
|
||||
all: clean test lint build
|
||||
|
||||
|
||||
.PHONY: checkfmt
|
||||
checkfmt: RESULT = $(shell goimports -l $(GOFILES) | tee >(if [ "$$(wc -l)" = 0 ]; then echo "OK"; fi))
|
||||
checkfmt: SHELL := /usr/bin/env bash
|
||||
checkfmt: ## Check formatting of all go files
|
||||
@ echo "$(RESULT)"
|
||||
@ if [ "$(RESULT)" != "OK" ]; then exit 1; fi
|
||||
|
||||
.PHONY: fmt
|
||||
fmt: ## Format all go files
|
||||
@ $(MAKE) --no-print-directory log-$@
|
||||
goimports -w $(GOFILES)
|
||||
|
||||
.PHONY: lint
|
||||
lint: ## Run linter
|
||||
@ $(MAKE) --no-print-directory log-$@
|
||||
GO111MODULE=on golangci-lint run ./...
|
||||
|
||||
.PHONY: clean
|
||||
clean: ## Clean workspace
|
||||
@ $(MAKE) --no-print-directory log-$@
|
||||
rm -rf ./$(BUILD_DIR)
|
||||
|
||||
.PHONY: build
|
||||
build: clean ## Build binary for current OS/ARCH
|
||||
@ $(MAKE) --no-print-directory log-$@
|
||||
$(GOBUILD) -o ./$(BUILD_DIR)/$(GOOS)-$(GOARCH)/$(NAME)
|
||||
|
||||
.PHONY: build-all
|
||||
build-all: GOOS = linux darwin
|
||||
build-all: GOARCH = amd64
|
||||
build-all: clean ## Build binary for all OS/ARCH
|
||||
@ $(MAKE) --no-print-directory log-$
|
||||
@ ./scripts/build/build-all-osarch.sh "$(BUILD_DIR)" "$(NAME)" "$(VERSION)" "$(GOOS)" "$(GOARCH)"
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
go test ./...
|
||||
$(GOCMD) test ./...
|
||||
|
||||
.PHONY: testacc
|
||||
testacc:
|
||||
TF_LOG=debug TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
|
||||
TF_LOG=debug TF_ACC=1 $(GOCMD) test $(TEST) -v $(TESTARGS) -timeout 120m
|
||||
|
||||
.PHONY: build test testacc
|
||||
.PHONY: gox
|
||||
gox:
|
||||
GO111MODULE=off go get -u github.com/mitchellh/gox
|
||||
|
||||
.PHONY: goimports
|
||||
goimports:
|
||||
GO111MODULE=off go get -u golang.org/x/tools/cmd/goimports
|
||||
|
||||
.PHONY: golangci
|
||||
golangci:
|
||||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(shell go env GOPATH)/bin $(GOLANGCI_VERSION)
|
||||
|
||||
|
||||
.PHONY: tools
|
||||
tools: ## Install required tools
|
||||
@ $(MAKE) --no-print-directory log-$@
|
||||
@ $(MAKE) --no-print-directory goimports golangci gox
|
||||
|
||||
log-%:
|
||||
@ grep -h -E '^$*:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m==> %s\033[0m\n", $$2}'
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
go build
|
||||
mv terraform-provider-confluent-cloud ~/.terraform.d/plugins/darwin_amd64/terraform-provider-confluentcloud
|
||||
cd examples
|
||||
terraform init
|
||||
terraform plan
|
||||
terraform output
|
||||
@@ -47,8 +47,8 @@ func kafkaClusterResource() *schema.Resource {
|
||||
Description: "LOW(single-zone) or HIGH(multi-zone)",
|
||||
ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) {
|
||||
v := val.(string)
|
||||
if val != "LOW" || val != "HIGH" {
|
||||
errs = append(errs, fmt.Errorf("%q must be `LOW` or `HIGH`, got: %d", key, v))
|
||||
if val != "LOW" && val != "HIGH" {
|
||||
errs = append(errs, fmt.Errorf("%q must be `LOW` or `HIGH`, got: %s", key, v))
|
||||
}
|
||||
return
|
||||
},
|
||||
|
||||
@@ -3,8 +3,6 @@ module github.com/Mongey/terraform-provider-confluent-cloud
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/cgroschupp/go-client-confluent-cloud v0.0.0-20191204162755-5bbf166f5417
|
||||
github.com/cgroschupp/go-client-confluent-cloud v0.0.0-20191211092310-656dfa7ae169
|
||||
github.com/hashicorp/terraform v0.12.1
|
||||
)
|
||||
|
||||
replace github.com/cgroschupp/go-client-confluent-cloud => ../go-client-confluent-cloud
|
||||
|
||||
@@ -50,6 +50,8 @@ github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBT
|
||||
github.com/bsm/go-vlq v0.0.0-20150828105119-ec6e8d4f5f4e/go.mod h1:N+BjUcTjSxc2mtRGSCPsat1kze3CUtvJN3/jTXlp29k=
|
||||
github.com/cgroschupp/go-client-confluent-cloud v0.0.0-20191204162755-5bbf166f5417 h1:qFpYAU2U8vodmGSpL32L979KEJ+64nAcxq9EsymNZag=
|
||||
github.com/cgroschupp/go-client-confluent-cloud v0.0.0-20191204162755-5bbf166f5417/go.mod h1:4qz2Pftxeus+mcGJkiysWrDwf/uQL1+jEI/Yu5BpS60=
|
||||
github.com/cgroschupp/go-client-confluent-cloud v0.0.0-20191211092310-656dfa7ae169 h1:psVjoO+FaSJA5aD7sy2VdVgRGvylUh86aKj9vi9jjcA=
|
||||
github.com/cgroschupp/go-client-confluent-cloud v0.0.0-20191211092310-656dfa7ae169/go.mod h1:4qz2Pftxeus+mcGJkiysWrDwf/uQL1+jEI/Yu5BpS60=
|
||||
github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20161106042343-c914be64f07d/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
@@ -330,6 +332,7 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73r
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190502183928-7f726cade0ab h1:9RfW3ktsOZxgo9YNbBAjq1FWzc/igwEcUzZz8IXgSbk=
|
||||
golang.org/x/net v0.0.0-20190502183928-7f726cade0ab/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8j4DQRpdYMnGn/bJUEU=
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
@@ -354,6 +357,7 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82 h1:vsphBvatvfbhlb4PO1BYSr9dzugGxJ/SQHoNufZJq1w=
|
||||
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
||||
Executable
+72
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
BUILD_DIR="${1:-bin}"
|
||||
NAME="${2:-terraform-provider-confluentcloud}"
|
||||
VERSION="$3"
|
||||
GOOS="${4:-"linux darwin windows freebsd"}"
|
||||
GOARCH="${5:-"amd64 arm"}"
|
||||
|
||||
if [ -z "${VERSION}" ]; then
|
||||
echo "Error: VERSION is missing. e.g. ./compress.sh <build_dir> <name> <version> <build_os_list> <build_arch_list> <build_ldflag>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PWD=$(cd $(dirname "$0") && pwd -P)
|
||||
BUILD_DIR="${PWD}/../../${BUILD_DIR}"
|
||||
|
||||
CGO_ENABLED=0 gox \
|
||||
-verbose \
|
||||
-ldflags "${GOLDFLAGS}" \
|
||||
-gcflags=-trimpath=`go env GOPATH` \
|
||||
-os="${GOOS}" \
|
||||
-arch="${GOARCH}" \
|
||||
-osarch="!darwin/arm" \
|
||||
-output="${BUILD_DIR}/{{.OS}}-{{.Arch}}/${NAME}" ${PWD}/../../
|
||||
|
||||
printf "\033[36m==> Compress binary\033[0m\n"
|
||||
|
||||
for platform in $(find ${BUILD_DIR} -mindepth 1 -maxdepth 1 -type d); do
|
||||
OSARCH=$(basename ${platform})
|
||||
FULLNAME="${NAME}-${VERSION}-${OSARCH}"
|
||||
|
||||
case "${OSARCH}" in
|
||||
"windows"*)
|
||||
if ! command -v zip >/dev/null; then
|
||||
echo "Error: cannot compress, 'zip' not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
zip -q -j ${BUILD_DIR}/${FULLNAME}.zip ${platform}/${NAME}.exe
|
||||
printf -- "--> %15s: bin/%s\n" "${OSARCH}" "${FULLNAME}.zip"
|
||||
|
||||
;;
|
||||
*)
|
||||
if ! command -v tar >/dev/null; then
|
||||
echo "Error: cannot compress, 'tar' not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tar -czf ${BUILD_DIR}/${FULLNAME}.tar.gz --directory ${platform}/ ${NAME}
|
||||
printf -- "--> %15s: bin/%s\n" "${OSARCH}" "${FULLNAME}.tar.gz"
|
||||
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
cd ${BUILD_DIR}
|
||||
touch ${NAME}-${VERSION}.sha256sum
|
||||
|
||||
for binary in $(find . -mindepth 1 -maxdepth 1 -type f | grep -v "${NAME}-${VERSION}.sha256sum" | sort); do
|
||||
binary=$(basename ${binary})
|
||||
|
||||
if command -v sha256sum >/dev/null; then
|
||||
sha256sum ${binary} >>${NAME}-${VERSION}.sha256sum
|
||||
elif command -v shasum >/dev/null; then
|
||||
shasum -a256 ${binary} >>${NAME}-${VERSION}.sha256sum
|
||||
fi
|
||||
done
|
||||
|
||||
cd - >/dev/null 2>&1
|
||||
printf -- "\n--> %15s: bin/%s\n" "sha256sum" "${NAME}-${VERSION}.sha256sum"
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
ARCH=go env GOARCH
|
||||
OS=go env GOOS
|
||||
|
||||
go build
|
||||
|
||||
mv bin/${OS}-${ARCH}/terraform-provider-confluentcloud ~/.terraform.d/plugins/${OS}_${ARCH}/
|
||||
cd examples
|
||||
terraform init
|
||||
terraform plan
|
||||
terraform output
|
||||
Reference in New Issue
Block a user