Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -sync-first flag to render template before processing with interval or watching #884

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions confd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/signal"
"runtime"
"syscall"
"time"

"github.com/kelseyhightower/confd/backends"
"github.com/kelseyhightower/confd/log"
Expand Down Expand Up @@ -38,6 +39,17 @@ func main() {
os.Exit(0)
}

if config.SyncFirst {
for {
if err := template.Process(config.TemplateConfig); err != nil {
log.Error(err.Error())
time.Sleep(5 * time.Second)
} else {
break
}
}
}

stopChan := make(chan bool)
doneChan := make(chan bool)
errChan := make(chan error, 10)
Expand Down
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Config struct {
PrintVersion bool
ConfigFile string
OneTime bool
SyncFirst bool
}

var config Config
Expand Down Expand Up @@ -70,6 +71,7 @@ func init() {
flag.StringVar(&config.Username, "username", "", "the username to authenticate as (only used with vault and etcd backends)")
flag.StringVar(&config.Password, "password", "", "the password to authenticate with (only used with vault and etcd backends)")
flag.BoolVar(&config.Watch, "watch", false, "enable watch support")
flag.BoolVar(&config.SyncFirst, "sync-first", false, "sync template first")
}

// initConfig initializes the confd configuration by first setting defaults,
Expand Down