mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-13 21:56:38 +01:00
Adds scopeUID config to enable multiple instances of Watchtower (#511)
* Adds scopeUID config to enable multiple instances of Watchtower * Adds tests for multiple instance support with scopeuid * Adds docs on scope monitoring and multiple instance support * Adds multiple instances docs to mkdocs config file * Changes multiple instances check and refactors naming for scope feature * Applies linter suggestions * Fixes documentation on Watchtower monitoring scope
This commit is contained in:
parent
5efb249a86
commit
6a18ee911e
14 changed files with 160 additions and 24 deletions
30
cmd/root.go
30
cmd/root.go
|
|
@ -30,6 +30,7 @@ var (
|
|||
notifier *notifications.Notifier
|
||||
timeout time.Duration
|
||||
lifecycleHooks bool
|
||||
scope string
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
|
|
@ -90,6 +91,9 @@ func PreRun(cmd *cobra.Command, args []string) {
|
|||
|
||||
enableLabel, _ = f.GetBool("label-enable")
|
||||
lifecycleHooks, _ = f.GetBool("enable-lifecycle-hooks")
|
||||
scope, _ = f.GetString("scope")
|
||||
|
||||
log.Debug(scope)
|
||||
|
||||
// configure environment vars for client
|
||||
err := flags.EnvConfig(cmd)
|
||||
|
|
@ -118,21 +122,10 @@ func PreRun(cmd *cobra.Command, args []string) {
|
|||
|
||||
// Run is the main execution flow of the command
|
||||
func Run(c *cobra.Command, names []string) {
|
||||
filter := filters.BuildFilter(names, enableLabel)
|
||||
filter := filters.BuildFilter(names, enableLabel, scope)
|
||||
runOnce, _ := c.PersistentFlags().GetBool("run-once")
|
||||
httpAPI, _ := c.PersistentFlags().GetBool("http-api")
|
||||
|
||||
if httpAPI {
|
||||
apiToken, _ := c.PersistentFlags().GetString("http-api-token")
|
||||
|
||||
if err := api.SetupHTTPUpdates(apiToken, func() { runUpdatesWithNotifications(filter) }); err != nil {
|
||||
log.Fatal(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
api.WaitForHTTPUpdates()
|
||||
}
|
||||
|
||||
if runOnce {
|
||||
if noStartupMessage, _ := c.PersistentFlags().GetBool("no-startup-message"); !noStartupMessage {
|
||||
log.Info("Running a one time update.")
|
||||
|
|
@ -143,10 +136,21 @@ func Run(c *cobra.Command, names []string) {
|
|||
return
|
||||
}
|
||||
|
||||
if err := actions.CheckForMultipleWatchtowerInstances(client, cleanup); err != nil {
|
||||
if err := actions.CheckForMultipleWatchtowerInstances(client, cleanup, scope); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if httpAPI {
|
||||
apiToken, _ := c.PersistentFlags().GetString("http-api-token")
|
||||
|
||||
if err := api.SetupHTTPUpdates(apiToken, func() { runUpdatesWithNotifications(filter) }); err != nil {
|
||||
log.Fatal(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
api.WaitForHTTPUpdates()
|
||||
}
|
||||
|
||||
if err := runUpgradesOnSchedule(c, filter); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue