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

feat: implement name server resource for domains #669

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

PhilippeVienne
Copy link
Contributor

@PhilippeVienne PhilippeVienne commented Jun 26, 2024

Sure, here's the completed PR template with the provided diff details:

Description

This pull request implements a new feature: the name server resource for domains. Using the /nameServers/update endpoint, this change allows users to update the Name Servers (NS) of a domain registered at OVHCloud. This resource requires a new testing resource of a Domain where the NS can be changed. The changes have been tested on a separate account with a restricted token to ensure proper functionality.

The following files have been updated:

  • README.md: Added OVH_DOMAIN_TEST environment variable for testing.
  • provider.go: Registered the new ovh_domain_name_servers resource.
  • provider_test.go: Included a check for OVH_DOMAIN_TEST.
  • resource_domain_name_servers.go: Implementation of the new resource.
  • resource_domain_name_servers_test.go: Test cases for the new resource.

Fixes #146 (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (improve existing resource(s) or datasource(s))
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

The changes have been tested on a separate account with a restricted token. The following tests were conducted to verify the new functionality:

  • Test A: make testacc TESTARGS="-run TestAccDomainNameServers_Basic" – This test verifies the basic functionality of updating the Name Servers for a domain.

Test Configuration:

  • Terraform version: terraform version: Terraform v1.8.3
  • Existing HCL configuration you used:
resource "ovh_domain_name_servers" "foobar" {
	  domain = "terraform-test.ovh"
	  server {
	  	  host = "dns104.ovh.net"
	  }
	  server {
	  	  host = "ns104.ovh.net"
	  }
}

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or issues
  • I have added acceptance tests that prove my fix is effective or that my feature works
  • New and existing acceptance tests pass locally with my changes
  • I ran successfully go mod vendor if I added or modify go.mod file

Using the /nameServers/update endpoint, we allow to update the NS of a domain registered at OVHCloud

Note that this resource require a new testing resource of a Domain where you can change the NS on it.
@PhilippeVienne
Copy link
Contributor Author

Hello @rbeuque74 , have you got any update for that PR ?

Copy link

@al26p al26p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

Copy link
Contributor

@amstuta amstuta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you're missing a doc page in website/docs/r

"strings"
)

type OvhDomainNameServerUpdate struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you place the structs in a file type_domain.go, to keep consistency with other resources ?

ovh/resource_domain_name_servers.go Show resolved Hide resolved
}

func resourceOvhDomainNameServersDelete(d *schema.ResourceData, meta interface{}) error {
// Note that NameServers can not be deleted, only updated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when deleting, shouldn't we call /domain/xxx/nameServers/update with an empty array ? If this doesn't work, you should call DELETE /domain/{serviceName}/nameServer/{id} on each nameServer to clean them.

}
rec := &([]int{})

endpoint := fmt.Sprintf("/domain/%s/nameServer", domain)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please url.PathEscape() all string path parameters

func ovhDomainNameServer(client *ovh.Client, domain string, id int) (*OvhDomainNameServer, error) {
rec := &OvhDomainNameServer{}

endpoint := fmt.Sprintf("/domain/%s/nameServer/%d", domain, id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment, to url.PathEscape()

})
}

func testSweepOvhDomainNameServers(region string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this func seems useless as it doesn't remove anything, or am I missing something ?

@amstuta
Copy link
Contributor

amstuta commented Oct 25, 2024

@PhilippeVienne any news on this PR ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New resource: ovh_domain
5 participants