Skip to content

Commit

Permalink
Add support for volumes blacklisting (fixes camptocamp#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanevet committed May 3, 2016
1 parent c35a7d0 commit 372eb7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions conplicity.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"sort"
"strings"
"unicode/utf8"

log "github.com/Sirupsen/logrus"
Expand Down Expand Up @@ -42,6 +44,14 @@ func backupVolume(c *handler.Conplicity, vol *docker.Volume) (err error) {
return
}

list := strings.Split(c.VolumesBlacklist, ",")
sort.Strings(list)
i := sort.SearchStrings(list, vol.Name)
if i < len(list) && list[i] == vol.Name {
log.Infof("Ignoring blacklisted volume " + vol.Name)
return
}

if getVolumeLabel(vol, ".ignore") == "true" {
log.Infof("Ignoring blacklisted volume " + vol.Name)
return
Expand Down
1 change: 1 addition & 0 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type environment struct {
SwiftRegionName string `env:"SWIFT_REGIONNAME"`
FullIfOlderThan string `env:"FULL_IF_OLDER_THAN" envDefault:"15D"`
RemoveOlderThan string `env:"REMOVE_OLDER_THAN" envDefault:"30D"`
VolumesBlacklist string `env:"CONPLICITY_VOLUMES_BLACKLIST"`
}

// Conplicity is the main handler struct
Expand Down

0 comments on commit 372eb7b

Please sign in to comment.