Skip to content

Commit

Permalink
Add initial sync to watch command
Browse files Browse the repository at this point in the history
  • Loading branch information
coufalja committed May 10, 2018
1 parent 37f3b98 commit e0e9ca8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cmd/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ var watchCmd = &cobra.Command{
}

var watchConfigmapCmd = &cobra.Command{
Use: "configmap",
Short: "Runs watcher that periodically check the provided repository and updates K8s ConfigMap accordingly",
Use: "configmap",
Short: "Runs watcher that periodically check the provided repository and updates K8s ConfigMap accordingly",
DisableFlagParsing: true,
RunE: func(c *cobra.Command, args []string) error {
return executeWatch(cmd.ConfigMap)
},
}

var watchSecretCmd = &cobra.Command{
Use: "secret",
Short: "Runs watcher that periodically check the provided repository and updates K8s Secret accordingly",
Use: "secret",
Short: "Runs watcher that periodically check the provided repository and updates K8s Secret accordingly",
DisableFlagParsing: true,
RunE: func(c *cobra.Command, args []string) error {
return executeWatch(cmd.Secret)
},
}

var watchFolderCmd = &cobra.Command{
Use: "folder",
Short: "Runs watcher that periodically check the provided repository and updates target folder accordingly",
Use: "folder",
Short: "Runs watcher that periodically check the provided repository and updates target folder accordingly",
DisableFlagParsing: true,
RunE: func(c *cobra.Command, args []string) error {
return executeWatch(cmd.Folder)
Expand Down Expand Up @@ -118,6 +118,13 @@ func executeWatch(lt cmd.LoadType) error {
up = uploader
}

err = refresh(fetcher, up)
if err != nil {
log.Errorf("Initial sync failed: %v", err)
return err
}
log.Info("Initial sync succeeded")

ticker := time.NewTicker(time.Duration(wp.interval) * time.Second)
stop := make(chan struct{})

Expand Down

0 comments on commit e0e9ca8

Please sign in to comment.