diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 6f51203..0000000 --- a/.github/stale.yml +++ /dev/null @@ -1,22 +0,0 @@ -# https://github.com/probot/stale - -daysUntilStale: 60 -daysUntilClose: 7 - -onlyLabels: [] -exemptLabels: - - help wanted - - good first issue - -exemptProjects: false -exemptMilestones: false -exemptAssignees: false - -staleLabel: stale - -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. - -limitPerRun: 30 diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 9619ea1..1b86eb1 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -13,9 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: - version: v1.49.0 + version: v1.59.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2081a8..b1bdc2f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,26 +10,26 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.22' - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2.5.0 + uses: docker/setup-buildx-action@v3.3.0 - name: Login to DockerHub - uses: docker/login-action@v2.1.0 + uses: docker/login-action@v3.2.0 with: username: aerialls password: ${{ secrets.DOCKER_HUB_TOKEN }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4.2.0 + uses: goreleaser/goreleaser-action@v5.1.0 with: version: latest args: release --rm-dist diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bcbf1b7..13f9a11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,15 +7,15 @@ jobs: name: Test strategy: matrix: - go: [ '1.20' ] + go: [ '1.22' ] platform: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} diff --git a/LICENSE b/LICENSE index 2ad443f..52426a9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2023 Julien Brochet +Copyright (c) 2020-2024 Julien Brochet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index a630041..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,15 +0,0 @@ -# Security Policy - -## Supported Versions - -The following versions are currently being supported with security updates. - -| Version | Supported | -|---------| ------------------ | -| 0.2.x | :white_check_mark: | -| 0.1.x | :x: | -| 0.0.x | :x: | - -## Reporting a Vulnerability - -To report a suspected vulnerability, please contact github@aerialls.io and include the steps to produce the vulnerability. diff --git a/cmd/scaleway-ddns/main.go b/cmd/scaleway-ddns/main.go index 912b119..e582299 100644 --- a/cmd/scaleway-ddns/main.go +++ b/cmd/scaleway-ddns/main.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "github.com/aerialls/scaleway-ddns/config" + ddnsconfig "github.com/aerialls/scaleway-ddns/config" "github.com/aerialls/scaleway-ddns/ddns" "github.com/aerialls/scaleway-ddns/notifier" "github.com/aerialls/scaleway-ddns/scaleway" @@ -14,10 +14,10 @@ import ( ) var ( - cfgFile string - verbose bool - logger *logrus.Logger - dryRun bool + configFile string + verbose bool + logger *logrus.Logger + dryRun bool ) var rootCmd = &cobra.Command{ @@ -26,31 +26,30 @@ var rootCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { logger.Info("starting dynamic records for Scaleway DNS") - cfg, err := config.NewConfig(cfgFile) + config, err := ddnsconfig.NewConfig(configFile) if err != nil { logger.Fatal(err) } dns, err := scaleway.NewDNS( logger, - cfg.ScalewayConfig.ProjectID, - cfg.ScalewayConfig.AccessKey, - cfg.ScalewayConfig.SecretKey, + config.ScalewayConfig.ProjectID, + config.ScalewayConfig.AccessKey, + config.ScalewayConfig.SecretKey, ) if err != nil { logger.Fatal(err) } - // Create a container to store all objects in one place - container := config.NewContainer(logger, cfg, dns) + container := ddnsconfig.NewContainer(logger, config, dns) - if cfg.TelegramConfig.Enabled { - tgCfg := cfg.TelegramConfig + if config.TelegramConfig.Enabled { + telegramConfig := config.TelegramConfig container.AddNotifier(notifier.NewTelegram( - tgCfg.Token, - tgCfg.ChatID, - tgCfg.Template, + telegramConfig.Token, + telegramConfig.ChatID, + telegramConfig.Template, )) } @@ -64,7 +63,7 @@ func init() { cobra.OnInitialize(initConfig) - rootCmd.Flags().StringVar(&cfgFile, "config", "", "config file") + rootCmd.Flags().StringVar(&configFile, "config", "", "config file") rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "enable verbose logging") rootCmd.Flags().BoolVarP(&dryRun, "dry-run", "d", false, "don't update DNS records") diff --git a/config/config.go b/config/config.go index b2ab3fa..0a160dd 100644 --- a/config/config.go +++ b/config/config.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) // NewConfig returns a new config object if the file exists @@ -14,20 +14,20 @@ func NewConfig(path string) (*Config, error) { return nil, fmt.Errorf("unable to load the config from file %s: %w", path, err) } - cfg := &Config{} - *cfg = DefaultConfig + config := &Config{} + *config = DefaultConfig - err = yaml.Unmarshal(data, &cfg) + err = yaml.Unmarshal(data, &config) if err != nil { return nil, err } - err = cfg.validate() + err = config.validate() if err != nil { return nil, err } - return cfg, nil + return config, nil } func (c *Config) validate() error { diff --git a/ddns/ddns.go b/ddns/ddns.go index 01a4bdd..168b099 100644 --- a/ddns/ddns.go +++ b/ddns/ddns.go @@ -147,7 +147,7 @@ func (d *DynamicDNSUpdater) UpdateRecord( notifiers := d.container.Notifiers for _, notifier := range notifiers { - err := notifier.Notify( + subErr := notifier.Notify( domain.Name, domain.Record, recordType, @@ -155,8 +155,8 @@ func (d *DynamicDNSUpdater) UpdateRecord( currentIP, ) - if err != nil { - logger.WithError(err).Errorf( + if subErr != nil { + logger.WithError(subErr).Errorf( "unable to notify the IP change with notifier %T", notifier, ) diff --git a/go.mod b/go.mod index c1760b6..ce778d6 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,14 @@ module github.com/aerialls/scaleway-ddns -go 1.20 +go 1.22 require ( - github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.16 - github.com/sirupsen/logrus v1.9.0 - github.com/spf13/cobra v1.7.0 - github.com/stretchr/testify v1.8.2 - github.com/technoweenie/multipartstreamer v1.0.1 // indirect - gopkg.in/yaml.v2 v2.4.0 + github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.28 + github.com/sirupsen/logrus v1.9.3 + github.com/spf13/cobra v1.8.1 + github.com/stretchr/testify v1.9.0 + gopkg.in/yaml.v3 v3.0.1 ) require ( @@ -17,6 +16,6 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/sys v0.8.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + golang.org/x/sys v0.21.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index bcdf5c0..2159196 100644 --- a/go.sum +++ b/go.sum @@ -1,35 +1,31 @@ -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU= -github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM= +github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc= +github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.16 h1:Ted1/3BGV1d0c7J+69N+brveAgJNWZlWnI8iYP3dZMs= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.16/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= -github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.28 h1:2vT+ryIQGfF21HN/W5yn/CBPpsTJULuuepWfUq/geV4= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.28/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM= -github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/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.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/notifier/telegram.go b/notifier/telegram.go index eca823b..4548d41 100644 --- a/notifier/telegram.go +++ b/notifier/telegram.go @@ -4,7 +4,7 @@ import ( "bytes" templating "text/template" - tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" + telegrambotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" ) // Telegram struct to be able to notify with Telegram messages @@ -44,7 +44,7 @@ func (t *Telegram) Notify( previousIP string, newIP string, ) error { - bot, err := tgbotapi.NewBotAPI(t.token) + bot, err := telegrambotapi.NewBotAPI(t.token) if err != nil { return err } @@ -65,7 +65,7 @@ func (t *Telegram) Notify( return err } - msg := tgbotapi.NewMessage(t.chatID, message) + msg := telegrambotapi.NewMessage(t.chatID, message) msg.ParseMode = "markdown" _, err = bot.Send(msg)