From a1f9b9a1c1a80ee4db8de66fe1b771fe8e28cd05 Mon Sep 17 00:00:00 2001 From: Alexandre Garand Date: Thu, 4 Jul 2019 13:31:58 +0200 Subject: [PATCH] add doc --- GNUmakefile | 17 ++++++ main.go | 2 +- scripts/changelog-links.sh | 31 +++++++++++ scripts/gogetcookie.sh | 10 ++++ website/docs/index.html.markdown | 63 ++++++++++++++++++++++ website/docs/r/domain.html.markdown | 84 +++++++++++++++++++++++++++++ website/docs/r/route.html.markdown | 51 ++++++++++++++++++ website/mailgun.erb | 29 ++++++++++ 8 files changed, 286 insertions(+), 1 deletion(-) create mode 100755 scripts/changelog-links.sh create mode 100755 scripts/gogetcookie.sh create mode 100644 website/docs/index.html.markdown create mode 100644 website/docs/r/domain.html.markdown create mode 100644 website/docs/r/route.html.markdown create mode 100644 website/mailgun.erb diff --git a/GNUmakefile b/GNUmakefile index 0e2ce73..f5f0c29 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,6 +1,7 @@ TEST?=$$(go list ./... |grep -v 'vendor') GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor) PKG_NAME=mailgun +WEBSITE_REPO=github.com/hashicorp/terraform-website default: build @@ -42,3 +43,19 @@ test-compile: fi go test -c $(TEST) $(TESTARGS) +website: +ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) + echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..." + git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO) +endif + @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) + +website-test: +ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) + echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..." + git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO) +endif + @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) + +.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile website website-test + diff --git a/main.go b/main.go index debeaa0..e433a0f 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/alexandreFre/terraform-provider-mailgun/mailgun" + "github.com/fretlink/terraform-provider-mailgun/mailgun" "github.com/hashicorp/terraform/plugin" ) diff --git a/scripts/changelog-links.sh b/scripts/changelog-links.sh new file mode 100755 index 0000000..303341b --- /dev/null +++ b/scripts/changelog-links.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# This script rewrites [GH-nnnn]-style references in the CHANGELOG.md file to +# be Markdown links to the given github issues. +# +# This is run during releases so that the issue references in all of the +# released items are presented as clickable links, but we can just use the +# easy [GH-nnnn] shorthand for quickly adding items to the "Unrelease" section +# while merging things between releases. + +set -e + +if [[ ! -f CHANGELOG.md ]]; then + echo "ERROR: CHANGELOG.md not found in pwd." + echo "Please run this from the root of the terraform provider repository" + exit 1 +fi + +if [[ `uname` == "Darwin" ]]; then + echo "Using BSD sed" + SED="sed -i.bak -E -e" +else + echo "Using GNU sed" + SED="sed -i.bak -r -e" +fi + +PROVIDER_URL="https:\/\/github.com\/terraform-providers\/terraform-provider-statuscake\/issues" + +$SED "s/GH-([0-9]+)/\[#\1\]\($PROVIDER_URL\/\1\)/g" -e 's/\[\[#(.+)([0-9])\)]$/(\[#\1\2))/g' CHANGELOG.md + +rm CHANGELOG.md.bak diff --git a/scripts/gogetcookie.sh b/scripts/gogetcookie.sh new file mode 100755 index 0000000..26c63a6 --- /dev/null +++ b/scripts/gogetcookie.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +touch ~/.gitcookies +chmod 0600 ~/.gitcookies + +git config --global http.cookiefile ~/.gitcookies + +tr , \\t <<\__END__ >>~/.gitcookies +.googlesource.com,TRUE,/,TRUE,2147483647,o,git-paul.hashicorp.com=1/z7s05EYPudQ9qoe6dMVfmAVwgZopEkZBb1a2mA5QtHE +__END__ diff --git a/website/docs/index.html.markdown b/website/docs/index.html.markdown new file mode 100644 index 0000000..fbdd1ba --- /dev/null +++ b/website/docs/index.html.markdown @@ -0,0 +1,63 @@ +--- +layout: "mailgun" +page_title: "Provider: Mailgun" +sidebar_current: "docs-mailgun-index" +description: |- + The Mailgun provider configures domains and routes in Mailgun. +--- + +# Mailgun Provider + +The Mailgun provider allows Terraform to create and configure domains and routes in [Mailgun](https://www.mailgun.com/). + +The provider configuration block accepts the following arguments: + +* ``domain`` - (Required) The domain name for the ressources created with the provider. May alternatively be set via the + ``MAILGUN_DOMAIN`` environment variable. + +* ``apikey`` - (Required) The API auth token to use when making requests. May alternatively + be set via the ``MAILGUN_APIKEY`` environment variable. + +Use the navigation to the left to read about the available resources. + +## Example Usage + +```hcl +provider "mailgun" { + domain = "domain.com" + apikey = "15ee99178cc7q6325df7ff8a15211228-2f778ta3-e04c2946" +} + +resource "mailgun_domain" "example" { + name="domain.com" + spam_action="block" + smtp_password="password" + wildcard=true + force_dkim_authority=true + dkim_key_size=1024 + ips=["192.161.0.1", "192.168.0.2"] + credentials{ + login="login" + password="password" + } + open_tracking_settings_active=true + click_tracking_settings_active=true + unsubscribe_tracking_settings_active=true + unsubscribe_tracking_settings_html_footer="

footer

" + unsubscribe_tracking_settings_text_footer="footer" + require_tls=true + skip_verification=true +} + +resource "mailgun_route" "example" { + depends_on = [mailgun_domain.example] + priority=5 + description="description" + expression="match_recipient(\".*@samples.mailgun.org\")" + actions=[ + "forward(\"http://myhost.com/messages/\")", + "stop()" + ] +} + +``` diff --git a/website/docs/r/domain.html.markdown b/website/docs/r/domain.html.markdown new file mode 100644 index 0000000..01d300f --- /dev/null +++ b/website/docs/r/domain.html.markdown @@ -0,0 +1,84 @@ +--- +layout: "mailgun" +page_title: "Mailgun: mailgun_domain" +sidebar_current: "docs-mailgun-domain" +description: |- + The domain_resource allows mailgun domain to be managed by Terraform. +--- + +# mailgun\_domain + +The domain resource allows Mailgun domain to be managed by Terraform. + +## Example Usage + +```hcl +resource "mailgun_domain" "example" { + name="domain.com" + spam_action="block" + smtp_password="password" + wildcard=true + force_dkim_authority=true + dkim_key_size=1024 + ips=["192.161.0.1", "192.168.0.2"] + credentials{ + login="login" + password="password" + } + open_tracking_settings_active=true + click_tracking_settings_active=true + unsubscribe_tracking_settings_active=true + unsubscribe_tracking_settings_html_footer="

footer

" + unsubscribe_tracking_settings_text_footer="footer" + require_tls=true + skip_verification=true +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Name of the domain +* `spam_action` - (Optional) "disabled", "block", or "tag".If "disabled", no spam filtering will occur for inbound messages.If "block", inbound spam messages will not be delivered.If "tag", inbound messages will be tagged with a spam header. See Spam Filter.Defaults to disabled. +* `smtp_password` - (Optional) Password for SMTP authentication +* `wildcard` - (Optional) Determines whether the domain will accept email for sub-domains when sending messages.Defaults to false. +* `force_dkim_authority` - (Optional) If set to true, the domain will be the DKIM authority for itself even if the root domain is registered on the same mailgun account.If set to false, the domain will have the same DKIM authority as the root domain registered on the same mailgun account. Defaults to false +* `dkim_key_size` - (Optional) 1024 or 2048. Set the length of your domain’s generated DKIM key. Defaults to 1024. +* `ips` - (Optional) An optional, comma-separated list of IP addresses to be assigned to this domain. If not specified, all dedicated IP addresses on the account will be assigned. If the request cannot be fulfilled (e.g. a requested IP is not assigned to the account, etc), a 400 will be returned. +* `credentials` - (Optional) SMTP credentials for the domain +* `open_tracking_settings_active` - (Optional) true to enable open tracking. Defauls to false +* `click_tracking_settings_active` - (Optional) true to enable click tracking. Defauls to false +* `unsubscribe_tracking_settings_active` - (Optional) true to enable unsubscribe tracking. Defauls to false +* `unsubscribe_tracking_settings_html_footer` - (Optional)Custom HTML version of unsubscribe footer.Defaults to "\n
\n

unsubscribe

\n" +* `unsubscribe_tracking_settings_text_footer` - (Optional) Custom text version of unsubscribe footer. Defaults to "\n\nTo unsubscribe click: <%unsubscribe_url%>\n\n" +* `require_tls` - (Optional) If set to true, this requires the message only be sent over a TLS connection. If a TLS connection can not be established, Mailgun will not deliver the message.If set to false, Mailgun will still try and upgrade the connection, but if Mailgun cannot, the message will be delivered over a plaintext SMTP connection. Defaults to false. +* `skip_verification` - (Optional)If set to true, the certificate and hostname will not be verified when trying to establish a TLS connection and Mailgun will accept any certificate during delivery. If set to false, Mailgun will verify the certificate and hostname. If either one can not be verified, a TLS connection will not be established. Defaults to false. +The `credentials` object supports the following: +* `login` - (Required) The user name +* `password` - (Required) A password for the SMTP credentials. (Length Min 5, Max 32) + +## Attributes Reference + +The following attribute is exported: + +* `smtp_login` - An username for the SMTP credentials. +* `created_at` - The date of creation of the domain. +* `state` - The state of the domain. +* `receiving_records` - DNS records for receiving. +* `sending_records` - DNS records for sending. +The `receiving_records` `sending_records` and object exports the following: +* `name` - The name of the record. +* `priority` - The priority of the record lower value means a more important priority. +* `record_type` - The type of record. +* `valid` - Wether the record is valid or not. +* `value` - The value of the record. + +## Import + +Mailgun domain can be imported using the domain name, e.g. + +``` +tf import mailgun_domain.example domain.com + +``` diff --git a/website/docs/r/route.html.markdown b/website/docs/r/route.html.markdown new file mode 100644 index 0000000..8452f01 --- /dev/null +++ b/website/docs/r/route.html.markdown @@ -0,0 +1,51 @@ +--- +layout: "mailgun" +page_title: "Mailgun: mailgun_route" +sidebar_current: "docs-mailgun-route" +description: |- + The route_resource allows mailgun route to be managed by Terraform. +--- + +# mailgun\_route + +The route resource allows Mailgun route to be managed by Terraform. + +## Example Usage + +```hcl +resource "mailgun_route" "example" { + priority=5 + description="description" + expression="match_recipient(\".*@samples.mailgun.org\")" + actions=[ + "forward(\"http://myhost.com/messages/\")", + "stop()" + ] +} +``` + +## Argument Reference + +The following arguments are supported: + +* `priority` - (Required)Integer: smaller number indicates higher priority. Higher priority routes are handled first. +* `expression` - (Required) An arbitrary string. +* `description` - (Required) A filter expression like match_recipient('.*@gmail.com') +* `actions` - (Required) Route action. This action is executed when the expression evaluates to True. Example: forward("alice@example.com") You can pass multiple action parameters. + + +## Attributes Reference + +The following attribute is exported: + +* `route_id` - ID of the route. +* `created_at` - The date of creation of the route. + +## Import + +Mailgun can be imported using the route ID, e.g. + +``` +tf import mailgun_route.example 4f3bad2335335426750048c6 + +``` diff --git a/website/mailgun.erb b/website/mailgun.erb new file mode 100644 index 0000000..4841bfe --- /dev/null +++ b/website/mailgun.erb @@ -0,0 +1,29 @@ +<% wrap_layout :inner do %> + <% content_for :sidebar do %> + + <% end %> + + <%= yield %> +<% end %> -- 2.41.0