Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate contact_id in certificate resource #62

Merged
merged 4 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## master

* Deprecate the use of `contact_id` in the `dnsimple_lets_encrypt_certificate` resource. The field is no longer in use and there is no replacement for it.

## 0.14.1

* Avoid panic when looking for a record and it does not exist on the prefetched list
Expand Down
14 changes: 3 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,9 @@ Our sandbox environment does not allow purchasing or issue certificates. For tha
`resource_dnsimple_lets_encrypt_certificate` you will have to run the tests in production
(setting `DNSIMPLE_SANDBOX=false` in the shell).

For the Let's Encrypt Resource you will...
have to go to the `resource_dnsimple_lets_encrypt_certificate_test` and change the `domain` (line 21)
to a real domain ID you want test against.

After that you will have to change the `testAccLetsEncrypConfig` (in that same file) changing the arguments marked:
- contact_id (required)
- and name (optional, but you might have to change it if you run the tests for a second time)

For the Certificate Data-Source you will...
have to go to the `datasource_dnsimple_certificate_test` and change the `certificate_id` in lines 26 and 39 to
a real certificate ID in the domain you are going to test against.
You will have to set the following env variables in your shell:
- `DNSIMPLE_CERTIFICATE_NAME` the name for which to request the certificate i.e. **www**
- `DNSIMPLE_CERTIFICATE_ID` the certificate ID used in the datasource test

## Sideload the plugin

Expand Down
6 changes: 3 additions & 3 deletions dnsimple/datasource_dnsimple_certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ func TestAccDNSimpleCertificateBasic(t *testing.T) {
ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(testAccCheckDNSimpleCertificateConfigBasic, domain),
Config: fmt.Sprintf(testAccCheckDNSimpleCertificateConfigBasic, domain, os.Getenv("DNSIMPLE_CERTIFICATE_ID")),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.dnsimple_certificate.foobar", "domain", domain),
resource.TestCheckResourceAttr(
"data.dnsimple_certificate.foobar", "certificate_id", "PROD_CERT_ID"),
"data.dnsimple_certificate.foobar", "certificate_id", os.Getenv("DNSIMPLE_CERTIFICATE_ID")),
),
},
},
Expand All @@ -36,5 +36,5 @@ func TestAccDNSimpleCertificateBasic(t *testing.T) {
const testAccCheckDNSimpleCertificateConfigBasic = `
data "dnsimple_certificate" "foobar" {
domain = "%s"
certificate_id = "USE A CERTIFICATE IN PROD (ALSO DON'T FORGET TO CHANGE IT IN LINE26)"
certificate_id = %s
}`
6 changes: 3 additions & 3 deletions dnsimple/resource_dnsimple_lets_encrypt_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ func resourceDNSimpleLetsEncryptCertificate() *schema.Resource {
Optional: true,
},
"contact_id": {
Type: schema.TypeInt,
Required: true,
Type: schema.TypeInt,
Optional: true,
Deprecated: "contact_id is deprecated and has no effect. The attribute will be removed in the next major version.",
},
"name": {
Type: schema.TypeString,
Expand Down Expand Up @@ -122,7 +123,6 @@ func resourceDNSimpleLetsEncryptCertificateCreate(ctx context.Context, data *sch
domainID := data.Get("domain_id").(string)

certificateAttributes := dnsimple.LetsencryptCertificateAttributes{
ContactID: int64(data.Get("contact_id").(int)),
AutoRenew: data.Get("auto_renew").(bool),
Name: data.Get("name").(string),
}
Expand Down
11 changes: 5 additions & 6 deletions dnsimple/resource_dnsimple_lets_encrypt_certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package dnsimple
import (
"context"
"fmt"
"github.com/dnsimple/dnsimple-go/dnsimple"
"os"
"strconv"
"testing"

_ "github.com/dnsimple/dnsimple-go/dnsimple"
"github.com/dnsimple/dnsimple-go/dnsimple"
DXTimer marked this conversation as resolved.
Show resolved Hide resolved
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)
Expand All @@ -18,13 +17,13 @@ func TestAccDNSimpleLetsEncryptCertificateCreate(t *testing.T) {

if sandbox == "false" {
var certificate dnsimple.Certificate
domain := "CHANGE ME TO THE ACTUAL DOMAIN ID"
domain := os.Getenv("DNSIMPLE_DOMAIN")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(testAccLetsEncryptConfig, domain),
Config: fmt.Sprintf(testAccLetsEncryptConfig, domain, os.Getenv("DNSIMPLE_CERTIFICATE_NAME")),
Check: resource.ComposeTestCheckFunc(
testAccCheckLetsEncryptCertificate("dnsimple_lets_encrypt_certificate.foobar", &certificate)),
},
Expand Down Expand Up @@ -72,7 +71,7 @@ func testAccCheckLetsEncryptCertificate(resourceName string, certificate *dnsimp
const testAccLetsEncryptConfig = `
resource "dnsimple_lets_encrypt_certificate" "foobar" {
domain_id = "%s"
contact_id = "FIND YOUR CONTACT ID IN THE ADMIN"
contact_id = 1234
auto_renew = false
name = "www"
name = "%s"
}`
5 changes: 2 additions & 3 deletions docs/resources/lets_encrypt_certificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Provides a DNSimple Let's Encrypt certificate resource.
```hcl
resource "dnsimple_lets_encrypt_certificate" "foobar" {
domain_id = "${var.dnsimple.domain_id}"
contact_id = "${var.dnsimple.contact_id}"
auto_renew = false
name = "www"
}
Expand All @@ -22,7 +21,7 @@ resource "dnsimple_lets_encrypt_certificate" "foobar" {
The following argument(s) are supported:

* `domain_id` - (Required) The domain to be issued the certificate for
* `contact_id` - (Required) The contact id for the certificate
* `contact_id` - (Deprecated) The contact id for the certificate

## Attribute Reference

Expand All @@ -36,4 +35,4 @@ The following attributes are exported:
* `state` - The state of the certificate
* `authority_identifier` - The identifying certification authority (CA)
* `auto_renew` - Set to true if the certificate will auto-renew
* `csr` - The certificate signing request
* `csr` - The certificate signing request