Skip to content

Commit

Permalink
Merge pull request #673 from nustiueudinastea/update-libdns-gandi
Browse files Browse the repository at this point in the history
upgrade Gandi libdns to 1.0.3
  • Loading branch information
foxcpp authored Jan 27, 2024
2 parents dd06ffe + 08671bc commit 394bc9e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/libdns/alidns v1.0.3-0.20230628155627-8d5d630d5516
github.com/libdns/cloudflare v0.1.1-0.20221006221909-9d3ab3c3cddd
github.com/libdns/digitalocean v0.0.0-20230728223659-4f9064657aea
github.com/libdns/gandi v1.0.3-0.20220921161957-dcd0274d2c79
github.com/libdns/gandi v1.0.3
github.com/libdns/googleclouddns v1.1.0
github.com/libdns/hetzner v0.0.1
github.com/libdns/leaseweb v0.3.1
Expand Down Expand Up @@ -168,3 +168,5 @@ require (
)

replace github.com/emersion/go-imap => github.com/foxcpp/go-imap v1.0.0-beta.1.0.20220623182312-df940c324887

replace github.com/libdns/gandi => github.com/foxcpp/libdns-gandi v1.0.4-0.20240127130558-4782f9d5ce3e // v1.0.3+maddy.1
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ github.com/foxcpp/go-mockdns v1.0.0 h1:7jBqxd3WDWwi/6WhDvacvH1XsN3rOLXyHM1uhvIx6
github.com/foxcpp/go-mockdns v1.0.0/go.mod h1:lgRN6+KxQBawyIghpnl5CezHFGS9VLzvtVlwxvzXTQ4=
github.com/foxcpp/go-mtasts v0.0.0-20191219193356-62bc3f1f74b8 h1:k8w0iy6GP9oeSZWUH3p2DqZHaXDKZGNs3NZGZMGfQHc=
github.com/foxcpp/go-mtasts v0.0.0-20191219193356-62bc3f1f74b8/go.mod h1:HO1YOCbBM8KjpgThMMFejHx6K/UsnEv2Oh9YGtBIlOU=
github.com/foxcpp/libdns-gandi v1.0.4-0.20240127130558-4782f9d5ce3e h1:hKk+CGUtwnKDGKINPEojeo91kx0tnV6V4tlzHehJPfg=
github.com/foxcpp/libdns-gandi v1.0.4-0.20240127130558-4782f9d5ce3e/go.mod h1:G6dw58Xnji2xX+lb+uZxGbtmfxKllm1CGHE2bOPG3WA=
github.com/frankban/quicktest v1.5.0/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
Expand Down Expand Up @@ -498,8 +500,6 @@ github.com/libdns/cloudflare v0.1.1-0.20221006221909-9d3ab3c3cddd h1:c5hc0b5/pFq
github.com/libdns/cloudflare v0.1.1-0.20221006221909-9d3ab3c3cddd/go.mod h1:ob9J/elFVmPWKNHOMynwtH0h+T3pBrEL18amCSliwAQ=
github.com/libdns/digitalocean v0.0.0-20230728223659-4f9064657aea h1:IGlMNZCUp8Ho7NYYorpP5ZJgg2mFXARs6eHs/pSqFkA=
github.com/libdns/digitalocean v0.0.0-20230728223659-4f9064657aea/go.mod h1:B2TChhOTxvBflpRTHlguXWtwa1Ha5WI6JkB6aCViM+0=
github.com/libdns/gandi v1.0.3-0.20220921161957-dcd0274d2c79 h1:s5zuoIehXkSKg6Yfd5Oh1jEfvWXSn+eAttVHufSzDPE=
github.com/libdns/gandi v1.0.3-0.20220921161957-dcd0274d2c79/go.mod h1:VN+Lh8Teq6nYszNsPSLKdIv24hOCcQu0rJWHQa2jPZc=
github.com/libdns/googleclouddns v1.1.0 h1:murPR1LfTZZObLV2OLxUVmymWH25glkMFKpDjkk2m0E=
github.com/libdns/googleclouddns v1.1.0/go.mod h1:3tzd056dfqKlf71V8Oy19En4WjJ3ybyuWx6P9bQSCIw=
github.com/libdns/hetzner v0.0.1 h1:WsmcsOKnfpKmzwhfyqhGQEIlEeEaEUvb7ezoJgBKaqU=
Expand Down
15 changes: 14 additions & 1 deletion internal/libdns/gandi.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
package libdns

import (
"fmt"

"github.com/foxcpp/maddy/framework/config"
"github.com/foxcpp/maddy/framework/log"
"github.com/foxcpp/maddy/framework/module"
"github.com/libdns/gandi"
)
Expand All @@ -16,7 +19,17 @@ func init() {
RecordDeleter: &p,
RecordAppender: &p,
setConfig: func(c *config.Map) {
c.String("api_token", false, true, "", &p.APIToken)
c.String("api_token", false, false, "", &p.APIToken)
c.String("personal_token", false, false, "", &p.BearerToken)
},
afterConfig: func() error {
if p.APIToken != "" {
log.Println("libdns.gandi: api_token is deprecated, use personal_token instead (https://api.gandi.net/docs/authentication/)")
}
if p.APIToken == "" && p.BearerToken == "" {
return fmt.Errorf("libdns.gandi: either api_token or personal_token should be specified")
}
return nil
},
instName: instName,
modName: modName,
Expand Down
8 changes: 7 additions & 1 deletion internal/libdns/provider_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
type ProviderModule struct {
libdns.RecordDeleter
libdns.RecordAppender
setConfig func(c *config.Map)
setConfig func(c *config.Map)
afterConfig func() error

instName string
modName string
Expand All @@ -17,6 +18,11 @@ type ProviderModule struct {
func (p *ProviderModule) Init(cfg *config.Map) error {
p.setConfig(cfg)
_, err := cfg.Process()
if p.afterConfig != nil {
if err := p.afterConfig(); err != nil {
return err
}
}
return err
}

Expand Down

0 comments on commit 394bc9e

Please sign in to comment.