Skip to content

Commit

Permalink
Merge pull request #2 from invidian/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
invidian committed Jun 15, 2019
2 parents eb3e257 + 949b439 commit f874ede
Show file tree
Hide file tree
Showing 10 changed files with 552 additions and 150 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## 0.2.0 (June 15, 2019)

* Add Terraform 0.12 compatibility
* Restructure code to standard layout
* Add Makefile to document common tasks

## 0.1.0 (April 12, 2019)

* Initial release
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod

# Terraform parameters
PROVIDER_NAME=terraform-provider-gpg
PROVIDER_VERSION=`git describe --tags --always | cut -d"-" -f1`
PROTOCOL_VERSION=x4
BINARY_NAME=$(PROVIDER_NAME)_$(PROVIDER_VERSION)_$(PROTOCOL_VERSION)

# Output parameters
OUTPUT_DIRECTORY=`pwd`
OUTPUT_FILE=$(OUTPUT_DIRECTORY)/$(BINARY_NAME)

# Build parameters
CGO_ENABLED=0
LD_FLAGS="-extldflags '-static'"

all: test build lint

test:
$(GOTEST) -v ./...

build:
CGO_ENABLED=$(CGO_ENABLED) $(GOBUILD) -o $(OUTPUT_FILE) -v -buildmode=exe -ldflags $(LD_FLAGS)

lint:
which golangci-lint 2>&1 >/dev/null && golangci-lint run || echo "'golangci-lint' binary not found, skipping linting."

clean:
$(GOCLEAN)
rm -f $(OUTPUT_FILE) || true
rm -f $(OUTPUT_FILE).sig || true

update:
$(GOGET) -u
$(GOMOD) tidy

# TODO Add GitHub integration
release: all pack sign

pack:
which upx 2>&1 >/dev/null && upx --brute $(OUTPUT_FILE) || echo "'upx' binary not found, skipping packing."

sign:
gpg --output $(OUTPUT_FILE).sig --detach-sig $(OUTPUT_FILE)
34 changes: 32 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,36 @@ module github.com/invidian/terraform-provider-gpg
go 1.12

require (
github.com/hashicorp/terraform v0.11.13
golang.org/x/crypto v0.0.0-20180211211603-9de5f2eaf759
cloud.google.com/go v0.40.0 // indirect
github.com/aws/aws-sdk-go v1.20.1 // indirect
github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-hclog v0.9.2 // indirect
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl2 v0.0.0-20190607155442-318e80eefe28 // indirect
github.com/hashicorp/hil v0.0.0-20190212132231-97b3a9cdfa93 // indirect
github.com/hashicorp/terraform v0.12.2
github.com/hashicorp/terraform-config-inspect v0.0.0-20190524144125-e2ee25ba1e5e // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/ulikunitz/xz v0.5.6 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
go.opencensus.io v0.22.0 // indirect
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 // indirect
golang.org/x/sys v0.0.0-20190614160838-b47fdc937951 // indirect
google.golang.org/appengine v1.6.1 // indirect
google.golang.org/genproto v0.0.0-20190611190212-a7e196e89fd3 // indirect
google.golang.org/grpc v1.21.1 // indirect
)

replace (
github.com/golang/lint => golang.org/x/lint v0.0.0-20190409202823-959b441ac422
// https://github.com/sourcegraph/go-diff/issues/34
sourcegraph.com/sourcegraph/go-diff v0.5.1 => github.com/sourcegraph/go-diff v0.5.1
)
571 changes: 432 additions & 139 deletions go.sum

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions provider.go → gpg/provider.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main
package gpg

import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)

func Provider() *schema.Provider {
func Provider() terraform.ResourceProvider {
return &schema.Provider{
ResourcesMap: map[string]*schema.Resource{
"gpg_encrypted_message": resourceGPGEncryptedMessage(),
Expand Down
22 changes: 22 additions & 0 deletions gpg/provider_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package gpg

import (
"testing"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)

var testProviders map[string]terraform.ResourceProvider

func init() {
testProviders = map[string]terraform.ResourceProvider{
"gpg": Provider(),
}
}

func TestProvider(t *testing.T) {
if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
t.Fatalf("err: %s", err)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package gpg

import (
"bytes"
Expand Down
1 change: 1 addition & 0 deletions gpg/resource_gpg_encrypted_message_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package gpg
7 changes: 2 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ package main

import (
"github.com/hashicorp/terraform/plugin"
"github.com/hashicorp/terraform/terraform"
"github.com/invidian/terraform-provider-gpg/gpg"
)

func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: func() terraform.ResourceProvider {
return Provider()
},
})
ProviderFunc: gpg.Provider})
}
1 change: 0 additions & 1 deletion resource_gpg_encrypted_message_test.go

This file was deleted.

0 comments on commit f874ede

Please sign in to comment.