cloudflare

package
v0.0.0-...-bcce8f3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CfDNSOperations

type CfDNSOperations interface {
	ZoneIDByName(zoneName string) (string, error)
	DNSRecords(zoneID string, rr cloudflare.DNSRecord) ([]cloudflare.DNSRecord, error)
	DNSRecord(zoneID, recordID string) (cloudflare.DNSRecord, error)
	CreateDNSRecord(zoneID string, rr cloudflare.DNSRecord) (*cloudflare.DNSRecordResponse, error)
	UpdateDNSRecord(zoneID, recordID string, rr cloudflare.DNSRecord) error
}

CloudflareOperations this is the implicit, partial interface of the relevant operations present in the official Cloudflare Golang SDK. By interfacing this we make easier to create test doubles and DI.

type DNSClient

type DNSClient interface {
	UpdateDNS(dnsName string, ipAddress string) error
	CreateDNS(dnsName string, ipAddress string) error
	DataForDNS(dnsName string) (string, error)
	UpsertDNSEntry(dnsName string, ipAddress string) error
	UpsertDNSEntries(dnsEntries []string, ipAddress string) error
}

DNSClient is the interface for the relevant DNS operations required.

The main implementation is a wrapper around Cloudflare Go SDK that allows managing DNS entries. More specifically, create, update or obtain A records (IP address) linked with a dns name. Zone should be created beforehand in Cloudflare. An valid API key and email are required to use the client.

Note: This interface should have a GCP implementation as well.

func NewFromEnv

func NewFromEnv(zoneName string) (DNSClient, error)

CF_API_KEY from gs://xxx-keys/cf-key.dec CF_EMAIL

func NewWithApiKey

func NewWithApiKey(zoneName string, apiKey string, accountEmail string) (DNSClient, error)

NewWithApiKey creates a new DNS client for Cloudflare passing in the zone name, API key, and account email

Jump to

Keyboard shortcuts

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