Skip to content

Commit

Permalink
Add support for NS1 DNS provider
Browse files Browse the repository at this point in the history
Closes #48
  • Loading branch information
janeczku committed Feb 5, 2017
1 parent 96428cf commit dab0b0b
Show file tree
Hide file tree
Showing 42 changed files with 3,551 additions and 14 deletions.
35 changes: 35 additions & 0 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func (c *Context) InitContext() {
OvhApplicationSecret: getEnvOption("OVH_APPLICATION_SECRET", false),
OvhConsumerKey: getEnvOption("OVH_CONSUMER_KEY", false),
GandiApiKey: getEnvOption("GANDI_API_KEY", false),
NS1ApiKey: getEnvOption("NS1_API_KEY", false),
}

c.Acme, err = letsencrypt.NewClient(emailParam, keyType, apiVersion, providerOpts)
Expand Down
47 changes: 33 additions & 14 deletions letsencrypt/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/xenolf/lego/providers/dns/dnsimple"
"github.com/xenolf/lego/providers/dns/dyn"
"github.com/xenolf/lego/providers/dns/gandi"
"github.com/xenolf/lego/providers/dns/ns1"
"github.com/xenolf/lego/providers/dns/ovh"
"github.com/xenolf/lego/providers/dns/route53"
"github.com/xenolf/lego/providers/dns/vultr"
Expand All @@ -21,6 +22,10 @@ import (
type ProviderOpts struct {
Provider Provider

// AWS Route 53 credentials
AwsAccessKey string
AwsSecretKey string

// Azure credentials
AzureClientId string
AzureClientSecret string
Expand All @@ -35,10 +40,6 @@ type ProviderOpts struct {
// DigitalOcean credentials
DoAccessToken string

// AWS Route 53 credentials
AwsAccessKey string
AwsSecretKey string

// DNSimple credentials
DNSimpleEmail string
DNSimpleKey string
Expand All @@ -48,16 +49,19 @@ type ProviderOpts struct {
DynUserName string
DynPassword string

// Vultr credentials
VultrApiKey string
// Gandi credentials
GandiApiKey string

// NS1 credentials
NS1ApiKey string

// OVH credentials
OvhApplicationKey string
OvhApplicationSecret string
OvhConsumerKey string

// Gandi credentials
GandiApiKey string
// Vultr credentials
VultrApiKey string
}

type Provider string
Expand All @@ -66,12 +70,13 @@ const (
AZURE = Provider("Azure")
CLOUDFLARE = Provider("CloudFlare")
DIGITALOCEAN = Provider("DigitalOcean")
ROUTE53 = Provider("Route53")
DNSIMPLE = Provider("DNSimple")
DYN = Provider("Dyn")
VULTR = Provider("Vultr")
OVH = Provider("Ovh")
GANDI = Provider("Gandi")
NS1 = Provider("NS1")
OVH = Provider("Ovh")
ROUTE53 = Provider("Route53")
VULTR = Provider("Vultr")
HTTP = Provider("HTTP")
)

Expand All @@ -84,12 +89,13 @@ var providerFactory = map[Provider]ProviderFactory{
AZURE: ProviderFactory{makeAzureProvider, lego.DNS01},
CLOUDFLARE: ProviderFactory{makeCloudflareProvider, lego.DNS01},
DIGITALOCEAN: ProviderFactory{makeDigitalOceanProvider, lego.DNS01},
ROUTE53: ProviderFactory{makeRoute53Provider, lego.DNS01},
DNSIMPLE: ProviderFactory{makeDNSimpleProvider, lego.DNS01},
DYN: ProviderFactory{makeDynProvider, lego.DNS01},
VULTR: ProviderFactory{makeVultrProvider, lego.DNS01},
OVH: ProviderFactory{makeOvhProvider, lego.DNS01},
GANDI: ProviderFactory{makeGandiProvider, lego.DNS01},
NS1: ProviderFactory{makeNS1Provider, lego.DNS01},
OVH: ProviderFactory{makeOvhProvider, lego.DNS01},
ROUTE53: ProviderFactory{makeRoute53Provider, lego.DNS01},
VULTR: ProviderFactory{makeVultrProvider, lego.DNS01},
HTTP: ProviderFactory{makeHTTPProvider, lego.HTTP01},
}

Expand Down Expand Up @@ -267,3 +273,16 @@ func makeAzureProvider(opts ProviderOpts) (lego.ChallengeProvider, error) {
}
return provider, nil
}

// returns a preconfigured NS1 lego.ChallengeProvider
func makeNS1Provider(opts ProviderOpts) (lego.ChallengeProvider, error) {
if len(opts.NS1ApiKey) == 0 {
return nil, fmt.Errorf("NS1 API key is not set")
}

provider, err := ns1.NewDNSProviderCredentials(opts.NS1ApiKey)
if err != nil {
return nil, err
}
return provider, nil
}
97 changes: 97 additions & 0 deletions vendor/github.com/xenolf/lego/providers/dns/ns1/ns1.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dab0b0b

Please sign in to comment.