From d1760a053770f3c8d46303789a24c3d11e4a7114 Mon Sep 17 00:00:00 2001 From: vanbroup Date: Wed, 21 Jun 2023 07:05:21 +0000 Subject: [PATCH] Update DNS Providers --- go.mod | 6 +++--- go.sum | 10 ++++++---- providers/autodns/autodns.go | 6 ++---- providers/designate/designate.toml | 2 +- providers/dnsmadeeasy/internal/client.go | 3 ++- providers/exec/exec.toml | 15 --------------- providers/pdns/pdns.go | 2 +- providers/route53/route53.go | 11 +++++++++-- providers/route53/route53.toml | 3 ++- providers/websupport/websupport.go | 14 ++------------ 10 files changed, 28 insertions(+), 44 deletions(-) diff --git a/go.mod b/go.mod index 36340a9..51ade8f 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/dnsimple/dnsimple-go v0.71.1 github.com/entrustcorporation/entrust v0.0.0-20230314134457-b6b1cf0dd3bb github.com/exoscale/egoscale v0.90.0 - github.com/go-acme/lego/v4 v4.11.0 + github.com/go-acme/lego/v4 v4.12.3 github.com/go-jose/go-jose/v3 v3.0.0 github.com/google/go-querystring v1.1.0 github.com/gophercloud/gophercloud v1.0.0 @@ -49,7 +49,7 @@ require ( github.com/sacloud/iaas-api-go v1.3.2 github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9 github.com/simplesurance/bunny-go v0.0.0-20221115111006-e11d9dc91f04 - github.com/sirupsen/logrus v1.9.0 + github.com/sirupsen/logrus v1.9.3 github.com/softlayer/softlayer-go v1.0.6 github.com/stretchr/testify v1.8.1 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.490 @@ -121,7 +121,7 @@ require ( go.uber.org/ratelimit v0.2.0 // indirect golang.org/x/crypto v0.7.0 // indirect golang.org/x/mod v0.8.0 // indirect - golang.org/x/sys v0.8.0 // indirect + golang.org/x/sys v0.9.0 // indirect golang.org/x/text v0.8.0 // indirect golang.org/x/tools v0.6.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index f1d6c31..49b5b00 100644 --- a/go.sum +++ b/go.sum @@ -134,8 +134,8 @@ github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= -github.com/go-acme/lego/v4 v4.11.0 h1:oIPoU7zBJoTfoVrbqk62+/2NsGCSgCVK1JtZSZZ28SU= -github.com/go-acme/lego/v4 v4.11.0/go.mod h1:dENL0J3/WughN2NLy0T35otK5k1EWCmXTwCw0+X5ZaE= +github.com/go-acme/lego/v4 v4.12.3 h1:aWPYhBopAZXWBASPgvi1LnWGrr5YiXOsrpVaFaVJipo= +github.com/go-acme/lego/v4 v4.12.3/go.mod h1:UZoOlhVmUYP/N0z4tEbfUjoCNHRZNObzqWZtT76DIsc= github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= github.com/go-cmd/cmd v1.0.5/go.mod h1:y8q8qlK5wQibcw63djSl/ntiHUHXHGdCkPk0j4QeW4s= github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= @@ -486,6 +486,8 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9 h1:hp2CYQUINdZMHdvTdXtPOY2ainKl4IoMcpAXEf2xj3Q= @@ -719,8 +721,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= diff --git a/providers/autodns/autodns.go b/providers/autodns/autodns.go index 65568b9..660cf6b 100644 --- a/providers/autodns/autodns.go +++ b/providers/autodns/autodns.go @@ -122,8 +122,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { Value: info.Value, }} - // TODO(ldez) replace domain by FQDN to follow CNAME. - _, err := d.client.AddTxtRecords(context.Background(), domain, records) + _, err := d.client.AddTxtRecords(context.Background(), info.EffectiveFQDN, records) if err != nil { return fmt.Errorf("autodns: %w", err) } @@ -142,8 +141,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { Value: info.Value, }} - // TODO(ldez) replace domain by FQDN to follow CNAME. - if err := d.client.RemoveTXTRecords(context.Background(), domain, records); err != nil { + if err := d.client.RemoveTXTRecords(context.Background(), info.EffectiveFQDN, records); err != nil { return fmt.Errorf("autodns: %w", err) } diff --git a/providers/designate/designate.toml b/providers/designate/designate.toml index b885999..045c235 100644 --- a/providers/designate/designate.toml +++ b/providers/designate/designate.toml @@ -65,4 +65,4 @@ For more information, you can read about the different methods of authentication [Links] API = "https://docs.openstack.org/designate/latest/" - GoClient = "https://godoc.org/github.com/gophercloud/gophercloud/openstack/dns/v2" + GoClient = "https://pkg.go.dev/github.com/gophercloud/gophercloud/openstack/dns/v2" diff --git a/providers/dnsmadeeasy/internal/client.go b/providers/dnsmadeeasy/internal/client.go index fe3d364..42fa2da 100644 --- a/providers/dnsmadeeasy/internal/client.go +++ b/providers/dnsmadeeasy/internal/client.go @@ -84,6 +84,7 @@ func (c *Client) GetRecords(ctx context.Context, domain *Domain, recordName, rec query := endpoint.Query() query.Set("recordName", recordName) query.Set("type", recordType) + endpoint.RawQuery = query.Encode() req, err := newJSONRequest(ctx, http.MethodGet, endpoint, nil) if err != nil { @@ -113,7 +114,7 @@ func (c *Client) CreateRecord(ctx context.Context, domain *Domain, record *Recor // DeleteRecord deletes a TXT records. func (c *Client) DeleteRecord(ctx context.Context, record Record) error { - endpoint := c.BaseURL.JoinPath("/dns/managed", strconv.Itoa(record.SourceID), "records", strconv.Itoa(record.ID)) + endpoint := c.BaseURL.JoinPath("dns", "managed", strconv.Itoa(record.SourceID), "records", strconv.Itoa(record.ID)) req, err := newJSONRequest(ctx, http.MethodDelete, endpoint, nil) if err != nil { diff --git a/providers/exec/exec.toml b/providers/exec/exec.toml index a274f07..52243fe 100644 --- a/providers/exec/exec.toml +++ b/providers/exec/exec.toml @@ -94,19 +94,4 @@ you can use the `--` delimiter to specify the start of positional arguments, and | default | `myprogram cleanup -- ` | | `RAW` | `myprogram cleanup -- ` | -### Timeout - -The command have to display propagation timeout and polling interval into Stdout. - -The values must be formatted as JSON, and times are in seconds. -Example: `{"timeout": 30, "interval": 5}` - -If an error occurs or if the command is not provided: -the default display propagation timeout and polling interval are used. - -| Mode | Command | -|---------|----------------------------------------------------| -| default | `myprogram timeout` | -| `RAW` | `myprogram timeout` | - ''' diff --git a/providers/pdns/pdns.go b/providers/pdns/pdns.go index de3f2d5..9f7c0ea 100644 --- a/providers/pdns/pdns.go +++ b/providers/pdns/pdns.go @@ -142,7 +142,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { } rec := internal.Record{ - Content: "\"" + info.EffectiveFQDN + "\"", + Content: "\"" + info.Value + "\"", Disabled: false, // pre-v1 API diff --git a/providers/route53/route53.go b/providers/route53/route53.go index 75c900f..34c9b95 100644 --- a/providers/route53/route53.go +++ b/providers/route53/route53.go @@ -30,6 +30,7 @@ const ( EnvHostedZoneID = envNamespace + "HOSTED_ZONE_ID" EnvMaxRetries = envNamespace + "MAX_RETRIES" EnvAssumeRoleArn = envNamespace + "ASSUME_ROLE_ARN" + EnvExternalID = envNamespace + "EXTERNAL_ID" EnvTTL = envNamespace + "TTL" EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT" @@ -48,6 +49,7 @@ type Config struct { HostedZoneID string MaxRetries int AssumeRoleArn string + ExternalID string TTL int PropagationTimeout time.Duration @@ -62,6 +64,7 @@ func NewDefaultConfig() *Config { HostedZoneID: env.GetOrFile(EnvHostedZoneID), MaxRetries: env.GetOrDefaultInt(EnvMaxRetries, 5), AssumeRoleArn: env.GetOrDefaultString(EnvAssumeRoleArn, ""), + ExternalID: env.GetOrDefaultString(EnvExternalID, ""), TTL: env.GetOrDefaultInt(EnvTTL, 10), PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 2*time.Minute), @@ -337,8 +340,12 @@ func createSession(config *Config) (*session.Session, error) { } return session.NewSession(&aws.Config{ - Region: sess.Config.Region, - Credentials: stscreds.NewCredentials(sess, config.AssumeRoleArn), + Region: sess.Config.Region, + Credentials: stscreds.NewCredentials(sess, config.AssumeRoleArn, func(arp *stscreds.AssumeRoleProvider) { + if config.ExternalID != "" { + arp.ExternalID = &config.ExternalID + } + }), }) } diff --git a/providers/route53/route53.toml b/providers/route53/route53.toml index 3b5f2a5..07e10d9 100644 --- a/providers/route53/route53.toml +++ b/providers/route53/route53.toml @@ -129,7 +129,8 @@ Replace `Z11111112222222333333` with your hosted zone ID and `example.com` with AWS_HOSTED_ZONE_ID = "Override the hosted zone ID." AWS_PROFILE = "Managed by the AWS client (`AWS_PROFILE_FILE` is not supported)" AWS_SDK_LOAD_CONFIG = "Managed by the AWS client. Retrieve the region from the CLI config file (`AWS_SDK_LOAD_CONFIG_FILE` is not supported)" - AWS_ASSUME_ROLE_ARN = "Managed by the AWS Role ARN (`AWS_ASSUME_ROLE_ARN` is not supported)" + AWS_ASSUME_ROLE_ARN = "Managed by the AWS Role ARN (`AWS_ASSUME_ROLE_ARN_FILE` is not supported)" + AWS_EXTERNAL_ID = "Managed by STS AssumeRole API operation (`AWS_EXTERNAL_ID_FILE` is not supported)" [Configuration.Additional] AWS_SHARED_CREDENTIALS_FILE = "Managed by the AWS client. Shared credentials file." AWS_MAX_RETRIES = "The number of maximum returns the service will use to make an individual API request" diff --git a/providers/websupport/websupport.go b/providers/websupport/websupport.go index e7622db..a3a15b0 100644 --- a/providers/websupport/websupport.go +++ b/providers/websupport/websupport.go @@ -133,12 +133,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { return nil } - err = internal.ParseError(resp) - if err != nil { - return fmt.Errorf("websupport: %w", err) - } - - return nil + return fmt.Errorf("websupport: %w", internal.ParseError(resp)) } // CleanUp removes the TXT record matching the specified parameters. @@ -172,12 +167,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return nil } - err = internal.ParseError(resp) - if err != nil { - return fmt.Errorf("websupport: %w", err) - } - - return nil + return fmt.Errorf("websupport: %w", internal.ParseError(resp)) } // Timeout returns the timeout and interval to use when checking for DNS propagation.