Skip to content

Add domain-zone record create and delete, commands#108

Merged
amstuta merged 17 commits intoovh:mainfrom
TheoBrigitte:domain-zone-record-create
Dec 11, 2025
Merged

Add domain-zone record create and delete, commands#108
amstuta merged 17 commits intoovh:mainfrom
TheoBrigitte:domain-zone-record-create

Conversation

@TheoBrigitte
Copy link
Contributor

Fixes #104

Description

This PR introduces 2 new domain-zone record sub-commands to create and delete DNS records.

The create command is similar to the update one which allow to use a file or the editor with a pre-filled schema. I've listed the records type in the --fieldType help text. Also I was unsure if I should use camel case or not for this flag. Most help texts have been taken straight out of the API documentation.
The delete command is fairly straightforward and just issue an HTTP Delete with to the right endpoint.

Tests have been added, along with docs.

Type of changea

  • New feature (non-breaking change which adds functionality)
  • Documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have commented my code
  • I updated the documentation by running make doc
  • I ran go mod tidy
  • I have added tests that prove my fix is effective or that my feature works

@TheoBrigitte TheoBrigitte requested a review from a team as a code owner November 29, 2025 00:09
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
Copy link
Collaborator

@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.

Thanks for your contribution @TheoBrigitte !

Just added a few comments but almost good to merge :)

TheoBrigitte and others added 4 commits December 1, 2025 10:33
Co-authored-by: Arthur Amstutz <18141571+amstuta@users.noreply.github.com>
Signed-off-by: Théo Brigitte <theo.brigitte@gmail.com>
Co-authored-by: Arthur Amstutz <18141571+amstuta@users.noreply.github.com>
Signed-off-by: Théo Brigitte <theo.brigitte@gmail.com>
Co-authored-by: Arthur Amstutz <18141571+amstuta@users.noreply.github.com>
Signed-off-by: Théo Brigitte <theo.brigitte@gmail.com>
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
@TheoBrigitte TheoBrigitte force-pushed the domain-zone-record-create branch from 608f47c to 7caa15f Compare December 1, 2025 09:37
}`),
)

out, err := cmd.Execute("domain-zone", "record", "create", "example.com", "--fieldType", "A", "--subdomain", "example-created", "--target", "127.0.0.1", "--ttl", "0")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
out, err := cmd.Execute("domain-zone", "record", "create", "example.com", "--fieldType", "A", "--subdomain", "example-created", "--target", "127.0.0.1", "--ttl", "0")
out, err := cmd.Execute("domain-zone", "record", "create", "example.com", "--field-type", "A", "--sub-domain", "example-created", "--target", "127.0.0.1", "--ttl", "0")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The subdomain flag will then become inconsistent with the one used in the update record command.

Copy link
Collaborator

Choose a reason for hiding this comment

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

oups my bad I missed this, in this case you're right we should keep subdomain everywhere

Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
@TheoBrigitte
Copy link
Contributor Author

My bad I had not pushed my changes. It should be alright now.

Copy link
Collaborator

@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.

Just a small change of URLs to use (prefix /v1 to add) and we're good to merge ;)

TheoBrigitte and others added 2 commits December 9, 2025 21:35
Co-authored-by: Arthur Amstutz <18141571+amstuta@users.noreply.github.com>
Signed-off-by: Théo Brigitte <theo.brigitte@gmail.com>
Co-authored-by: Arthur Amstutz <18141571+amstuta@users.noreply.github.com>
Signed-off-by: Théo Brigitte <theo.brigitte@gmail.com>
@TheoBrigitte
Copy link
Contributor Author

Alright, should be good now :)

@amstuta
Copy link
Collaborator

amstuta commented Dec 11, 2025

@TheoBrigitte you have some tests failing due to the URL change (I think). Could you fix them, and then we'll be able to merge ? :)

@TheoBrigitte
Copy link
Contributor Author

That's fixed :)

Signed-off-by: Theo Brigitte <theo.brigitte@gmail.com>
@TheoBrigitte TheoBrigitte force-pushed the domain-zone-record-create branch from c5a1e57 to 275b014 Compare December 11, 2025 09:23
@amstuta amstuta merged commit 08eb50e into ovh:main Dec 11, 2025
3 checks passed
@DavidGOrtega
Copy link

These commands do not appear in the CLI!!!??? My version is 0.9.0 @TheoBrigitte @amstuta

ovhcloud domain-zone record --help
Retrieve information and manage your DNS records within a zone

Usage:
  ovhcloud domain-zone record [command]

Available Commands:
  get         Get a single DNS record from your zone
  update      Update a single DNS record from your zone

Flags:
  -h, --help   help for record

Global Flags:
  -d, --debug           Activate debug mode (will log all HTTP requests details)
  -f, --format string   Output value according to given format (expression using https://github.com/PaesslerAG/gval syntax)
                        Examples:
                          --format 'id' (to extract a single field)
                          --format 'nested.field.subfield' (to extract a nested field)
                          --format '[id, 'name']' (to extract multiple fields as an array)
                          --format '{"newKey": oldKey, "otherKey": nested.field}' (to extract and rename fields in an object)
                          --format 'name+","+type' (to extract and concatenate fields in a string)
                          --format '(nbFieldA + nbFieldB) * 10' (to compute values from numeric fields)
  -e, --ignore-errors   Ignore errors in API calls when it is not fatal to the execution
  -i, --interactive     Interactive output
  -j, --json            Output in JSON
  -y, --yaml            Output in YAML

Use "ovhcloud domain-zone record [command] --help" for more information about a command.

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.

[Feature]: subcommand to create a DNS record

3 participants