-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For: libdns/libdns#139 Replaces: till/libdns-autodns#1
- Loading branch information
Showing
11 changed files
with
625 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export AUTODNS_USERNAME= | ||
export AUTODNS_PASSWORD= | ||
export AUTODNS_CONTEXT= | ||
export TEST_ZONE= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.envrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,45 @@ | ||
**DEVELOPER INSTRUCTIONS:** | ||
|
||
This repo is a template for developers to use when creating new [libdns](https://github.com/libdns/libdns) provider implementations. | ||
\<autodns\> for [`libdns`](https://github.com/libdns/libdns) | ||
======================= | ||
|
||
Be sure to update: | ||
[![Go Reference](https://pkg.go.dev/badge/test.svg)](https://pkg.go.dev/github.com/libdns/autodns) | ||
|
||
- 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 | ||
This package implements the [libdns interfaces](https://github.com/libdns/libdns) for \<autodns\>, allowing you to manage DNS records. | ||
|
||
Remove this section from the readme before publishing. | ||
Example: | ||
|
||
--- | ||
``` | ||
package main | ||
\<PROVIDER NAME\> for [`libdns`](https://github.com/libdns/libdns) | ||
======================= | ||
import ( | ||
"context" | ||
"os" | ||
"log" | ||
"github.com/libdns/autodns" | ||
) | ||
func main() { | ||
provider := autodns.Provider{ | ||
Username: os.Getenv("AUTODNS_USERNAME"), | ||
Password: os.Getenv("AUTODNS_PASSWORD"), | ||
} | ||
records, err := provider.GetRecords(context.TODO(), "zone.example.org") | ||
if err != nil { | ||
log.Fatalf("unexpected error: %s", err) | ||
} | ||
[![Go Reference](https://pkg.go.dev/badge/test.svg)](https://pkg.go.dev/github.com/libdns/TODO:PROVIDER_NAME) | ||
fmt.Printf("%#v", records) | ||
} | ||
``` | ||
|
||
This package implements the [libdns interfaces](https://github.com/libdns/libdns) for \<PROVIDER\>, allowing you to manage DNS records. | ||
As an alternative, configure the provider struct with the following: | ||
|
||
TODO: Show how to configure and use. Explain any caveats. | ||
| Field | Description (default) | Required | | ||
|------------|----------------------------|----------| | ||
| Username | username, empty | yes | | ||
| Password | password, empty | yes | | ||
| Endpoint | https://api.autodns.com/v1 | no | | ||
| Context | 4 | no | | ||
| HttpClient | `&http.Client{}` | no | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module github.com/libdns/template | ||
module github.com/libdns/autodns | ||
|
||
go 1.18 | ||
|
||
require github.com/libdns/libdns v0.2.1 | ||
require github.com/libdns/libdns v0.2.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
github.com/libdns/libdns v0.2.1 h1:Wu59T7wSHRgtA0cfxC+n1c/e+O3upJGWytknkmFEDis= | ||
github.com/libdns/libdns v0.2.1/go.mod h1:yQCXzk1lEZmmCPa857bnk4TsOiqYasqpyOEeSObbb40= | ||
github.com/libdns/libdns v0.2.2 h1:O6ws7bAfRPaBsgAYt8MDe2HcNBGC29hkZ9MX2eUSX3s= | ||
github.com/libdns/libdns v0.2.2/go.mod h1:4Bj9+5CQiNMVGf87wjX4CY3HQJypUHRuLvlsfsZqLWQ= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package autodns_test | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
|
||
"github.com/libdns/autodns" | ||
) | ||
|
||
func TestProvider(t *testing.T) { | ||
if os.Getenv("AUTODNS_USERNAME") == "" || os.Getenv("AUTODNS_PASSWORD") == "" { | ||
t.Skip() | ||
} | ||
|
||
provider := autodns.NewWithDefaults(os.Getenv("AUTODNS_USERNAME"), os.Getenv("AUTODNS_PASSWORD")) | ||
|
||
t.Run("GetRecords", func(t *testing.T) { | ||
if os.Getenv("TEST_ZONE") == "" { | ||
t.Skip() | ||
} | ||
|
||
records, err := provider.GetRecords(context.TODO(), os.Getenv("TEST_ZONE")) | ||
if err != nil { | ||
t.Fatalf("unexpected error: %s", err) | ||
} | ||
|
||
if len(records) == 0 { | ||
t.Fatalf("expected at least one record: %#v", records) | ||
} | ||
}) | ||
|
||
} |
Oops, something went wrong.