Skip to content
Open
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
54 changes: 54 additions & 0 deletions cmd/scw/testdata/test-all-usage-dns-record-import-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Import DNS records into a zone that uses Scaleway default name servers.

The DNS zone is the only positional argument; pass the path to the file as file=PATH.

Two formats are supported:
- bind: standard zone file (BIND), same family of syntax as "scw dns zone import".
Supported types: A, AAAA, CNAME, TXT, MX, NS, PTR, SRV, CAA. For other types (e.g. TLSA, SSHFP, DS), use format=json.
- json: UTF-8 JSON object with a "records" array; each element has name, type, ttl, data, and optional priority (for MX).
Accepts all types supported by the Scaleway DNS API.

SOA records and apex NS records in a BIND file are skipped. $INCLUDE and $GENERATE are rejected.

Use "replace=true" to delete all existing records in the zone before importing (equivalent to "scw dns record clear" followed by adds).

For a full zone file replacement at once, prefer "scw dns zone import".

USAGE:
scw dns record import <dns-zone ...> [arg=value ...]

EXAMPLES:
Import BIND records from a file
scw dns record import my-domain.tld file=./zone.txt

Import JSON and replace existing records
scw dns record import my-domain.tld file=./records.json format=json replace=true

ARGS:
dns-zone DNS zone to import records into
file Path to the zone file (bind) or JSON file
[format=bind] File format: "bind" or "json" (bind | json)
[dry-run=false] Parse the file and print a summary without calling the API
[replace=false] Clear all records in the zone before importing

FLAGS:
-h, --help help for import
--list-sub-commands List all subcommands

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use

SEE ALSO:
# Import a full raw DNS zone
dns zone import

# Low-level record changes
dns record bulk-update

# Delete all records in a zone
dns record clear
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-dns-record-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ AVAILABLE COMMANDS:
bulk-update Update records within a DNS zone
clear Clear records within a DNS zone
delete Delete a DNS record
import Import many DNS records from a file
list List records within a DNS zone
list-nameservers List name servers within a DNS zone
set Update a DNS record
Expand Down
53 changes: 53 additions & 0 deletions docs/commands/dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This API allows you to manage your domains, DNS zones and records.
- [Update records within a DNS zone](#update-records-within-a-dns-zone)
- [Clear records within a DNS zone](#clear-records-within-a-dns-zone)
- [Delete a DNS record](#delete-a-dns-record)
- [Import many DNS records from a file](#import-many-dns-records-from-a-file)
- [List records within a DNS zone](#list-records-within-a-dns-zone)
- [List name servers within a DNS zone](#list-name-servers-within-a-dns-zone)
- [Update a DNS record](#update-a-dns-record)
Expand Down Expand Up @@ -316,6 +317,58 @@ scw dns record delete my-domain.tld data=1.2.3.4 name=vpn type=A



### Import many DNS records from a file

Import DNS records into a zone that uses Scaleway default name servers.

The DNS zone is the only positional argument; pass the path to the file as file=PATH.

Two formats are supported:
- bind: standard zone file (BIND), same family of syntax as "scw dns zone import".
Supported types: A, AAAA, CNAME, TXT, MX, NS, PTR, SRV, CAA. For other types (e.g. TLSA, SSHFP, DS), use format=json.
- json: UTF-8 JSON object with a "records" array; each element has name, type, ttl, data, and optional priority (for MX).
Accepts all types supported by the Scaleway DNS API.

SOA records and apex NS records in a BIND file are skipped. $INCLUDE and $GENERATE are rejected.

Use "replace=true" to delete all existing records in the zone before importing (equivalent to "scw dns record clear" followed by adds).

For a full zone file replacement at once, prefer "scw dns zone import".

**Usage:**

```
scw dns record import <dns-zone ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| dns-zone | Required | DNS zone to import records into |
| file | Required | Path to the zone file (bind) or JSON file |
| format | Default: `bind`<br />One of: `bind`, `json` | File format: "bind" or "json" |
| dry-run | Default: `false` | Parse the file and print a summary without calling the API |
| replace | Default: `false` | Clear all records in the zone before importing |


**Examples:**


Import BIND records from a file
```
scw dns record import my-domain.tld file=./zone.txt
```

Import JSON and replace existing records
```
scw dns record import my-domain.tld file=./records.json format=json replace=true
```




### List records within a DNS zone

Retrieve a list of DNS records within a DNS zone that has default name servers.
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/karrick/tparse/v2 v2.8.2
github.com/mattn/go-colorable v0.1.14
github.com/mattn/go-isatty v0.0.21
github.com/miekg/dns v1.1.72
github.com/moby/buildkit v0.29.0
github.com/moby/go-archive v0.2.0
github.com/opencontainers/go-digest v1.0.0
Expand Down Expand Up @@ -204,11 +205,11 @@ require (
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirect
golang.org/x/mod v0.34.0 // indirect
golang.org/x/net v0.52.0 // indirect
golang.org/x/mod v0.35.0 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.43.0 // indirect
golang.org/x/tools v0.44.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260203192932-546029d2fa20 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260217215200-42d3e9bedb6d // indirect
google.golang.org/grpc v1.79.3 // indirect
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ github.com/mattn/go-tty v0.0.4 h1:NVikla9X8MN0SQAqCYzpGyXv0jY7MNl3HOWD2dkle7E=
github.com/mattn/go-tty v0.0.4/go.mod h1:u5GGXBtZU6RQoKV8gY5W6UhMudbR5vXnUe7j3pxse28=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/miekg/dns v1.1.72 h1:vhmr+TF2A3tuoGNkLDFK9zi36F2LS+hKTRW0Uf8kbzI=
github.com/miekg/dns v1.1.72/go.mod h1:+EuEPhdHOsfk6Wk5TT2CzssZdqkmFhf8r+aVyDEToIs=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/ioprogress v0.0.0-20180201004757-6a23b12fa88e h1:Qa6dnn8DlasdXRnacluu8HzPts0S1I9zvvUPDbBnXFI=
Expand Down Expand Up @@ -604,8 +606,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.34.0 h1:xIHgNUUnW6sYkcM5Jleh05DvLOtwc6RitGHbDk4akRI=
golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY=
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
Expand All @@ -618,8 +620,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -686,8 +688,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.43.0 h1:12BdW9CeB3Z+J/I/wj34VMl8X+fEXBxVR90JeMX5E7s=
golang.org/x/tools v0.43.0/go.mod h1:uHkMso649BX2cZK6+RpuIPXS3ho2hZo4FVwfoy1vIk0=
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
1 change: 1 addition & 0 deletions internal/namespaces/domain/v2beta1/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func GetCommands() *core.Commands {
dnsRecordAddCommand(),
dnsRecordSetCommand(),
dnsRecordDeleteCommand(),
dnsRecordImportCommand(),
))

cmds.MustFind("dns", "zone", "import").ArgSpecs.GetByName("bind-source.content").CanLoadFile = true
Expand Down
Loading
Loading