--- /dev/null
+TEST?=$$(go list ./... |grep -v 'vendor')
+GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
+PKG_NAME=mailgun
+
+default: build
+
+build: fmtcheck
+ go install
+
+test: fmtcheck
+ go test -i $(TEST) || exit 1
+ echo $(TEST) | \
+ xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
+
+testacc: fmtcheck
+ TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
+
+vet:
+ @echo "go vet ."
+ @go vet $$(go list ./... | grep -v vendor/) ; 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
+
+fmt:
+ gofmt -w $(GOFMT_FILES)
+
+fmtcheck:
+ @sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
+
+errcheck:
+ @sh -c "'$(CURDIR)/scripts/errcheck.sh'"
+
+
+test-compile:
+ @if [ "$(TEST)" = "./..." ]; then \
+ echo "ERROR: Set TEST to a specific package. For example,"; \
+ echo " make test-compile TEST=./$(PKG_NAME)"; \
+ exit 1; \
+ fi
+ go test -c $(TEST) $(TESTARGS)
+
--- /dev/null
+package mailgun
+
+import (
+ "github.com/hashicorp/terraform/helper/schema"
+ "github.com/hashicorp/terraform/terraform"
+ "github.com/mailgun/mailgun-go"
+)
+
+func Provider() terraform.ResourceProvider {
+ return &schema.Provider{
+ Schema: map[string]*schema.Schema{
+ "domain": {
+ Type: schema.TypeString,
+ Required: true,
+ DefaultFunc: schema.EnvDefaultFunc("MAILGUN_DOMAIN", nil),
+ Description: "domain for mailgun.",
+ },
+ "apikey": {
+ Type: schema.TypeString,
+ Required: true,
+ DefaultFunc: schema.EnvDefaultFunc("MAILGUN_APIKEY", nil),
+ Description: "API Key for mailgun",
+ },
+ },
+
+ ResourcesMap: map[string]*schema.Resource{},
+
+ ConfigureFunc: providerConfigure,
+ }
+}
+
+func providerConfigure(d *schema.ResourceData) (interface{}, error) {
+ return mailgun.NewMailgun(d.Get("domain").(string), d.Get("apikey").(string)), nil
+}
--- /dev/null
+package mailgun
+
+import (
+ "os"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/schema"
+ "github.com/hashicorp/terraform/terraform"
+)
+
+var testAccProviders map[string]terraform.ResourceProvider
+var testAccProvider *schema.Provider
+
+func init() {
+ testAccProvider = Provider().(*schema.Provider)
+ testAccProviders = map[string]terraform.ResourceProvider{
+ "mailgun": testAccProvider,
+ }
+}
+
+func TestProvider(t *testing.T) {
+ if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
+ t.Fatalf("err: %s", err)
+ }
+}
+
+func TestProvider_impl(t *testing.T) {
+ var _ terraform.ResourceProvider = Provider()
+}
+
+func testAccPreCheck(t *testing.T) {
+ if v := os.Getenv("MAILGUN_DOMAIN"); v == "" {
+ t.Fatal("MAILGUN_DOMAIN must be set for acceptance tests")
+ }
+ if v := os.Getenv("MAILGUN_APIKEY"); v == "" {
+ t.Fatal("MAILGUN_APIKEY must be set for acceptance tests")
+ }
+}
--- /dev/null
+package main
+
+import (
+ "github.com/alexandreFre/terraform-provider-mailgun/mailgun"
+ "github.com/hashicorp/terraform/plugin"
+)
+
+func main() {
+ plugin.Serve(&plugin.ServeOpts{
+ ProviderFunc: mailgun.Provider})
+}
--- /dev/null
+#!/usr/bin/env bash
+
+# Check gofmt
+echo "==> Checking for unchecked errors..."
+
+if ! which errcheck > /dev/null; then
+ echo "==> Installing errcheck..."
+ go get -u github.com/kisielk/errcheck
+fi
+
+err_files=$(errcheck -ignoretests \
+ -ignore 'github.com/hashicorp/terraform/helper/schema:Set' \
+ -ignore 'bytes:.*' \
+ -ignore 'io:Close|Write' \
+ $(go list ./...| grep -v /vendor/))
+
+if [[ -n ${err_files} ]]; then
+ echo 'Unchecked errors found in the following places:'
+ echo "${err_files}"
+ echo "Please handle returned errors. You can check directly with \`make errcheck\`"
+ exit 1
+fi
+
+exit 0
--- /dev/null
+#!/usr/bin/env bash
+
+# Check gofmt
+echo "==> Checking that code complies with gofmt requirements..."
+gofmt_files=$(gofmt -l `find . -name '*.go' | grep -v vendor`)
+if [[ -n ${gofmt_files} ]]; then
+ echo 'gofmt needs running on the following files:'
+ echo "${gofmt_files}"
+ echo "You can use the command: \`make fmt\` to reformat code."
+ exit 1
+fi
+
+exit 0