Skip to content

Commit b920955

Browse files
authored
Initial commit
0 parents  commit b920955

5 files changed

Lines changed: 107 additions & 0 deletions

File tree

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) <TODO: YEAR AND NAME>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
**DEVELOPER INSTRUCTIONS:**
2+
3+
This repo is a template for developers to use when creating new [libdns](https://github.com/libdns/libdns) provider implementations.
4+
5+
Be sure to update:
6+
7+
- The package name
8+
- The Go module name in go.mod
9+
- The latest `libdns/libdns` version in go.mod
10+
- All comments and documentation, including README below and godocs
11+
- License (must be compatible with Apache/MIT)
12+
- All "TODO:"s is in the code
13+
- All methods that currently do nothing
14+
15+
Remove this section from the readme before publishing.
16+
17+
---
18+
19+
\<PROVIDER NAME\> for [`libdns`](https://github.com/libdns/libdns)
20+
=======================
21+
22+
[![Go Reference](https://pkg.go.dev/badge/test.svg)](https://pkg.go.dev/github.com/libdns/TODO:PROVIDER_NAME)
23+
24+
This package implements the [libdns interfaces](https://github.com/libdns/libdns) for \<PROVIDER\>, allowing you to manage DNS records.
25+
26+
TODO: Show how to configure and use. Explain any caveats.

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/libdns/template
2+
3+
go 1.18
4+
5+
require github.com/libdns/libdns v0.2.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/libdns/libdns v0.2.1 h1:Wu59T7wSHRgtA0cfxC+n1c/e+O3upJGWytknkmFEDis=
2+
github.com/libdns/libdns v0.2.1/go.mod h1:yQCXzk1lEZmmCPa857bnk4TsOiqYasqpyOEeSObbb40=

provider.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Package libdnstemplate implements a DNS record management client compatible
2+
// with the libdns interfaces for <PROVIDER NAME>. TODO: This package is a
3+
// template only. Customize all godocs for actual implementation.
4+
package libdnstemplate
5+
6+
import (
7+
"context"
8+
"fmt"
9+
10+
"github.com/libdns/libdns"
11+
)
12+
13+
// TODO: Providers must not require additional provisioning steps by the callers; it
14+
// should work simply by populating a struct and calling methods on it. If your DNS
15+
// service requires long-lived state or some extra provisioning step, do it implicitly
16+
// when methods are called; sync.Once can help with this, and/or you can use a
17+
// sync.(RW)Mutex in your Provider struct to synchronize implicit provisioning.
18+
19+
// Provider facilitates DNS record manipulation with <TODO: PROVIDER NAME>.
20+
type Provider struct {
21+
// TODO: put config fields here (with snake_case json
22+
// struct tags on exported fields), for example:
23+
APIToken string `json:"api_token,omitempty"`
24+
}
25+
26+
// GetRecords lists all the records in the zone.
27+
func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error) {
28+
return nil, fmt.Errorf("TODO: not implemented")
29+
}
30+
31+
// AppendRecords adds records to the zone. It returns the records that were added.
32+
func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {
33+
return nil, fmt.Errorf("TODO: not implemented")
34+
}
35+
36+
// SetRecords sets the records in the zone, either by updating existing records or creating new ones.
37+
// It returns the updated records.
38+
func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {
39+
return nil, fmt.Errorf("TODO: not implemented")
40+
}
41+
42+
// DeleteRecords deletes the records from the zone. It returns the records that were deleted.
43+
func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) {
44+
return nil, fmt.Errorf("TODO: not implemented")
45+
}
46+
47+
// Interface guards
48+
var (
49+
_ libdns.RecordGetter = (*Provider)(nil)
50+
_ libdns.RecordAppender = (*Provider)(nil)
51+
_ libdns.RecordSetter = (*Provider)(nil)
52+
_ libdns.RecordDeleter = (*Provider)(nil)
53+
)

0 commit comments

Comments
 (0)