Documentation
¶
Overview ¶
Package domainchief implements a DNS record management client compatible with the libdns interfaces for Domain Chief (https://domain.chief.app) hosted DNS.
TXT records on `_acme-challenge` names holding an ACME challenge value are published and removed through the dedicated ACME challenge endpoints, so solving ACME DNS-01 challenges only requires an API token with the `domainchief:acme:write` scope. All other operations use the DNS record endpoints: reading records requires the `domainchief:dns:read` scope and changing them requires the `domainchief:dns:write` scope, which includes `domainchief:dns:read`. ListZones requires the `domainchief:domains:read` scope.
Index ¶
- Constants
- type APIError
- type Provider
- func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
- func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
- func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)
- func (p *Provider) ListZones(ctx context.Context) ([]libdns.Zone, error)
- func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
Constants ¶
const DefaultBaseURL = "https://domain.chief.app/api/v1"
DefaultBaseURL is the base URL of the Domain Chief API.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
// StatusCode is the HTTP status code of the response.
StatusCode int
// Code is the machine readable error code, if the API returned one (for example `dns.not_hosted`).
Code string
// Message is the human readable error message, including validation errors.
Message string
}
APIError is returned when the Domain Chief API responds with an unexpected status code.
type Provider ¶
type Provider struct {
// APIToken is a Domain Chief API token. Create one at https://account.chief.app/team/select/token/create.
//
// For ACME DNS-01 challenges only the `domainchief:acme:write` scope is needed.
APIToken string `json:"api_token,omitempty"`
// BaseURL overrides the Domain Chief API base URL, defaults to DefaultBaseURL.
BaseURL string `json:"base_url,omitempty"`
// HTTPClient overrides the HTTP client used for API requests.
HTTPClient *http.Client `json:"-"`
// contains filtered or unexported fields
}
Provider facilitates DNS record manipulation with Domain Chief hosted DNS.
The zone passed to the methods is the domain name in Domain Chief, for example `example.com.`. The domain must use hosted DNS.
func (*Provider) AppendRecords ¶
func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
AppendRecords adds records to the zone. It returns the records that were added.
ACME challenge TXT records on `_acme-challenge` names are published through the ACME challenge endpoint, which keeps other values on the same name and returns the existing record when the value is already published.
func (*Provider) DeleteRecords ¶
func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
DeleteRecords deletes the specified records from the zone. It returns the records that were deleted.
ACME challenge TXT records on `_acme-challenge` names with a value are removed through the ACME challenge endpoint. That endpoint does not report whether the value existed, so the input record is always returned.
func (*Provider) GetRecords ¶
GetRecords lists all the records in the zone.
Record types without a libdns struct type (ALIAS and TLSA) are returned as libdns.RR.
func (*Provider) SetRecords ¶
func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
SetRecords sets the records in the zone, either by updating existing records or creating new ones. It returns the records that were set.
For every (name, type) pair in the input, existing records with the same value are kept, other existing records are updated to hold the remaining values and leftover records are deleted. This is not atomic, when an error is returned some of the changes may have been applied.