hetzner

package module
v2.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2025 License: MIT Imports: 9 Imported by: 1

README

Hetzner DNS for libdns

godoc reference

This package implements the libdns interfaces for the Hetzner DNS APIs.

Authenticating

To authenticate, you need to supply a Hetzner Cloud API token.

Example

See examples and provider_test.go.

License

MIT

Documentation

Overview

Package hetzner implements the libdns(https://github.com/libdns/libdns) interfaces for the Hetzner Cloud DNS API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// APIToken is the Hetzner Cloud API token to use with HTTP requests. If not set, it defaults to the
	// LIBDNS_HETZNER_TOKEN environment variable.
	//
	// See https://docs.hetzner.cloud/reference/cloud#getting-started to learn how to generate a new token.
	APIToken string `json:"api_token,omitempty"`
	// contains filtered or unexported fields
}

Provider implements the libdns interfaces for the Hetzner DNS API.

func New

func New(token string) *Provider

New returns a new libdns provider for Hetzner.

If token is empty, the provider will default to the LIBDNS_HETZNER_TOKEN environment variable.

func (*Provider) AppendRecords

func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) (
	[]libdns.Record, error,
)

AppendRecords creates the inputted records in the given zone and returns the populated records that were created. This function fulfills the libdns.RecordAppender interface.

Please note that appending records may fail if the TTL doesn't match an existing RRset. For example,

;; Original zone
example.com. 3600 IN TXT "hello world"

;; Input
example.com. 60   IN TXT "hello world as well"

will fail, as the given TTL of 60s conflicts with TTL 3600s of the existing RRset identified by (example.com., TXT).

func (*Provider) DeleteRecords

func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) (
	[]libdns.Record, error,
)

DeleteRecords deletes the given records from the zone if they exist in the zone and exactly match the input. If the input records do not exist in the zone, they are silently ignored. DeleteRecords returns only the records that were deleted, and does not return any records that were provided in the input but did not exist in the zone. This function fulfills the libdns.RecordDeleter interface.

func (*Provider) GetRecords

func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)

GetRecords returns all the records in the DNS zone. This function fulfills the libdns.RecordGetter interface.

This implementation includes DNSSEC-related records.

func (*Provider) ListZones

func (p *Provider) ListZones(ctx context.Context) ([]libdns.Zone, error)

ListZones returns the list of available DNS zones for use by other functions. This function fulfills the libdns.ZoneLister interface.

func (*Provider) SetRecords

func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) (
	[]libdns.Record, error,
)

SetRecords updates the zone so that the records described in the input are reflected in the output. It returns the records which were set. Errors may result in partial changes to the zone. This function fulfills the libdns.RecordSetter interface.

This implementation supports setting DNSSEC-related records.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL