commit 99c2ad08d2b3189f6ecb42eb97db980f889f5d32 Author: Matthew Holt Date: Wed Feb 24 10:10:35 2021 -0700 Initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bc1194c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5ebbe61 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +**DEVELOPER INSTRUCTIONS:** + +This repo is a template for developers to use when creating new [libdns](https://github.com/libdns/libdns) provider implementations. + +Be sure to update: + +- The package name +- The Go module name in go.mod +- The latest `libdns/libdns` version in go.mod +- All comments and documentation, including README below and godocs +- License (must be compatible with Apache/MIT) +- All "TODO:"s is in the code +- All methods that currently do nothing + +Remove this section from the readme before publishing. + +--- + +\ for [`libdns`](https://github.com/libdns/libdns) +======================= + +[![Go Reference](https://pkg.go.dev/badge/test.svg)](https://pkg.go.dev/github.com/libdns/TODO:PROVIDER_NAME) + +This package implements the [libdns interfaces](https://github.com/libdns/libdns) for \, allowing you to manage DNS records. + +TODO: Show how to configure and use. Explain any caveats. diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..74ca7c8 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/libdns/template + +go 1.16 + +require github.com/libdns/libdns v0.2.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..aa85df9 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/libdns/libdns v0.2.0 h1:ewg3ByWrdUrxrje8ChPVMBNcotg7H9LQYg+u5De2RzI= +github.com/libdns/libdns v0.2.0/go.mod h1:yQCXzk1lEZmmCPa857bnk4TsOiqYasqpyOEeSObbb40= diff --git a/provider.go b/provider.go new file mode 100644 index 0000000..ea8a2f4 --- /dev/null +++ b/provider.go @@ -0,0 +1,53 @@ +// Package libdnstemplate implements a DNS record management client compatible +// with the libdns interfaces for . TODO: This package is a +// template only. Customize all godocs for actual implementation. +package libdnstemplate + +import ( + "context" + "fmt" + + "github.com/libdns/libdns" +) + +// TODO: Providers must not require additional provisioning steps by the callers; it +// should work simply by populating a struct and calling methods on it. If your DNS +// service requires long-lived state or some extra provisioning step, do it implicitly +// when methods are called; sync.Once can help with this, and/or you can use a +// sync.(RW)Mutex in your Provider struct to synchronize implicit provisioning. + +// Provider facilitates DNS record manipulation with . +type Provider struct { + // TODO: put config fields here (with snake_case json + // struct tags on exported fields), for example: + APIToken string `json:"api_token,omitempty"` +} + +// GetRecords lists all the records in the zone. +func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error) { + return nil, fmt.Errorf("TODO: not implemented") +} + +// AppendRecords adds records to the zone. It returns the records that were added. +func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) { + return nil, fmt.Errorf("TODO: not implemented") +} + +// SetRecords sets the records in the zone, either by updating existing records or creating new ones. +// It returns the updated records. +func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) { + return nil, fmt.Errorf("TODO: not implemented") +} + +// DeleteRecords deletes the records from the zone. It returns the records that were deleted. +func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) { + return nil, fmt.Errorf("TODO: not implemented") +} + +// Interface guards +var ( + _ libdns.RecordGetter = (*Provider)(nil) + _ libdns.RecordAppender = (*Provider)(nil) + _ libdns.RecordSetter = (*Provider)(nil) + _ libdns.RecordDeleter = (*Provider)(nil) +)