Skip to content

Commit

Permalink
Merge pull request #120 from aerialls/golang122
Browse files Browse the repository at this point in the history
chore: update dependencies
  • Loading branch information
aerialls authored Jul 2, 2024
2 parents ad0eabf + cba5824 commit 4966f72
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 106 deletions.
22 changes: 0 additions & 22 deletions .github/stale.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 0 additions & 15 deletions SECURITY.md

This file was deleted.

33 changes: 16 additions & 17 deletions cmd/scaleway-ddns/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand All @@ -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,
))
}

Expand All @@ -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")

Expand Down
12 changes: 6 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions ddns/ddns.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,16 @@ func (d *DynamicDNSUpdater) UpdateRecord(

notifiers := d.container.Notifiers
for _, notifier := range notifiers {
err := notifier.Notify(
subErr := notifier.Notify(
domain.Name,
domain.Record,
recordType,
scalewayIP,
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,
)
Expand Down
19 changes: 9 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
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 (
github.com/davecgh/go-spew v1.1.1 // indirect
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
)
30 changes: 13 additions & 17 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
6 changes: 3 additions & 3 deletions notifier/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
Expand Down

0 comments on commit 4966f72

Please sign in to comment.