Skip to content

Commit

Permalink
fix: set a default interval
Browse files Browse the repository at this point in the history
  • Loading branch information
luisdavim committed Nov 17, 2024
1 parent fc9a245 commit f27cfc0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ urlMap:
name: my-other-cm
key: config.json
namespace: foo
interval: 5m # how frequently to download, defaults to 60s
"https://fs.example.com/secret":
type: Secret
name: my-other-secret
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/luisdavim/configmapper

go 1.22.0

toolchain go1.23.2
go 1.23

require (
github.com/fsnotify/fsnotify v1.8.0
Expand Down
8 changes: 7 additions & 1 deletion pkg/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import (
"github.com/luisdavim/configmapper/pkg/utils"
)

const DefaultKey = "config"
const (
DefaultKey = "config"
DefaultInterval = time.Minute
)

type Downloader struct {
config config.URLMap
Expand Down Expand Up @@ -67,6 +70,9 @@ func New(cfg config.URLMap) (*Downloader, error) {
c.Key = DefaultKey
}
}
if c.Interval.Duration == 0 {
c.Interval.Duration = DefaultInterval
}
}

return d, nil
Expand Down

0 comments on commit f27cfc0

Please sign in to comment.