Skip to content

Commit

Permalink
Merge pull request #15 from wgebis/update_tf_sdk_add_dkim_selector
Browse files Browse the repository at this point in the history
Upgrade SDK, add dkim_selector
  • Loading branch information
wgebis authored May 12, 2021
2 parents 1703248 + e3d9a61 commit bed3892
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 109 deletions.
1 change: 1 addition & 0 deletions docs/resources/domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The following arguments are supported:
* `wildcard` - (Optional) Boolean that determines whether
the domain will accept email for sub-domains.
* `dkim_key_size` - (Optional) The length of your domain’s generated DKIM key. Default value is `1024`.
* `dkim_selector` - (Optional) The name of your DKIM selector if you want to specify it whereas MailGun will make it's own choice.

## Attributes Reference

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.14

require (
github.com/hashicorp/go-uuid v1.0.2
github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.4
github.com/mailgun/mailgun-go/v3 v3.6.4
github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.1
github.com/mailgun/mailgun-go/v4 v4.5.1

)
206 changes: 104 additions & 102 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mailgun/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mailgun

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/mailgun/mailgun-go/v3"
"github.com/mailgun/mailgun-go/v4"
"log"
"strings"
)
Expand Down
17 changes: 16 additions & 1 deletion mailgun/resource_mailgun_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/mailgun/mailgun-go/v3"
"github.com/mailgun/mailgun-go/v4"
)

func resourceMailgunDomain() *schema.Resource {
Expand Down Expand Up @@ -60,6 +60,12 @@ func resourceMailgunDomain() *schema.Resource {
Optional: true,
},

"dkim_selector": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},

"receiving_records": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -175,6 +181,7 @@ func resourceMailgunDomainCreate(ctx context.Context, d *schema.ResourceData, me
opts.Password = d.Get("smtp_password").(string)
opts.Wildcard = d.Get("wildcard").(bool)
opts.DKIMKeySize = d.Get("dkim_key_size").(int)
var dkimSelector = d.Get("dkim_selector").(string)

log.Printf("[DEBUG] Domain create configuration: %#v", opts)

Expand All @@ -184,6 +191,14 @@ func resourceMailgunDomainCreate(ctx context.Context, d *schema.ResourceData, me
return diag.FromErr(err)
}

if dkimSelector != "" {
errc = client.UpdateDomainDkimSelector(ctx, d.Get("name").(string), dkimSelector)

if errc != nil {
return diag.FromErr(errc)
}
}

d.SetId(name)

log.Printf("[INFO] Domain ID: %s", d.Id())
Expand Down
2 changes: 1 addition & 1 deletion mailgun/resource_mailgun_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/mailgun/mailgun-go/v3"
"github.com/mailgun/mailgun-go/v4"
)

func TestAccMailgunDomain_Basic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion mailgun/resource_mailgun_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"time"

"github.com/mailgun/mailgun-go/v3"
"github.com/mailgun/mailgun-go/v4"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down
2 changes: 1 addition & 1 deletion mailgun/resource_mailgun_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/mailgun/mailgun-go/v3"
"github.com/mailgun/mailgun-go/v4"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down

0 comments on commit bed3892

Please sign in to comment.