├── .gitignore ├── docker-compose.yml ├── go.mod ├── main.go ├── src ├── pusher │ └── pusher.go ├── reporter │ └── reporter.go └── scanner │ └── scanner.go ├── cmd ├── fill.go ├── copy.go └── root.go ├── README.md ├── go.sum └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.5' 2 | services: 3 | redis-source: 4 | image: redis:6.2-alpine 5 | ports: 6 | - "63791:6379" 7 | redis-dest: 8 | image: redis:6.2-alpine 9 | ports: 10 | - "63792:6379" -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/obukhov/go-redis-migrate 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/mediocregopher/radix/v3 v3.2.0 7 | github.com/mitchellh/go-homedir v1.1.0 8 | github.com/spf13/cobra v0.0.3 9 | github.com/spf13/viper v1.3.1 10 | ) 11 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Aleksandr Obukhov 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import "github.com/obukhov/go-redis-migrate/cmd" 18 | 19 | func main() { 20 | cmd.Execute() 21 | } 22 | -------------------------------------------------------------------------------- /src/pusher/pusher.go: -------------------------------------------------------------------------------- 1 | package pusher 2 | 3 | import ( 4 | "github.com/mediocregopher/radix/v3" 5 | "github.com/obukhov/go-redis-migrate/src/reporter" 6 | "github.com/obukhov/go-redis-migrate/src/scanner" 7 | "log" 8 | "sync" 9 | ) 10 | 11 | func NewRedisPusher(client radix.Client, dumpChannel <-chan scanner.KeyDump, reporter *reporter.Reporter) *RedisPusher { 12 | return &RedisPusher{ 13 | client: client, 14 | reporter: reporter, 15 | dumpChannel: dumpChannel, 16 | } 17 | } 18 | 19 | type RedisPusher struct { 20 | client radix.Client 21 | reporter *reporter.Reporter 22 | dumpChannel <-chan scanner.KeyDump 23 | } 24 | 25 | func (p *RedisPusher) Start(wg *sync.WaitGroup, number int) { 26 | wg.Add(number) 27 | for i := 0; i < number; i++ { 28 | go p.pushRoutine(wg) 29 | } 30 | 31 | } 32 | 33 | func (p *RedisPusher) pushRoutine(wg *sync.WaitGroup) { 34 | for dump := range p.dumpChannel { 35 | p.reporter.AddPushedCounter(1) 36 | err := p.client.Do(radix.FlatCmd(nil, "RESTORE", dump.Key, dump.Ttl, dump.Value, "REPLACE")) 37 | if err != nil { 38 | log.Fatal(err) 39 | } 40 | } 41 | 42 | wg.Done() 43 | } 44 | -------------------------------------------------------------------------------- /src/reporter/reporter.go: -------------------------------------------------------------------------------- 1 | package reporter 2 | 3 | import ( 4 | "log" 5 | "sync/atomic" 6 | "time" 7 | ) 8 | 9 | func NewReporter() *Reporter { 10 | return &Reporter{ 11 | doneChannel: make(chan bool), 12 | } 13 | } 14 | 15 | type Reporter struct { 16 | scannedCount uint64 17 | exportedCount uint64 18 | pushedCount uint64 19 | 20 | start time.Time 21 | doneChannel chan bool 22 | } 23 | 24 | func (r *Reporter) Start(reportPeriod time.Duration) { 25 | atomic.StoreUint64(&r.scannedCount, 0) 26 | atomic.StoreUint64(&r.exportedCount, 0) 27 | atomic.StoreUint64(&r.pushedCount, 0) 28 | 29 | r.start = time.Now() 30 | 31 | go r.reportingRoutine(reportPeriod) 32 | } 33 | 34 | func (r *Reporter) Stop() { 35 | r.doneChannel <- true 36 | } 37 | 38 | func (r *Reporter) AddScannedCounter(delta uint64) { 39 | atomic.AddUint64(&r.scannedCount, delta) 40 | } 41 | func (r *Reporter) AddExportedCounter(delta uint64) { 42 | atomic.AddUint64(&r.exportedCount, delta) 43 | } 44 | func (r *Reporter) AddPushedCounter(delta uint64) { 45 | atomic.AddUint64(&r.pushedCount, delta) 46 | } 47 | 48 | func (r *Reporter) Report() { 49 | log.Printf( 50 | "Scanned: %d Exported: %d Pushed: %d after %s\n", 51 | atomic.LoadUint64(&r.scannedCount), 52 | atomic.LoadUint64(&r.exportedCount), 53 | atomic.LoadUint64(&r.pushedCount), 54 | time.Since(r.start), 55 | ) 56 | } 57 | 58 | func (r *Reporter) reportingRoutine(reportPeriod time.Duration) { 59 | timer := time.NewTicker(reportPeriod) 60 | for { 61 | select { 62 | case <-timer.C: 63 | r.Report() 64 | case <-r.doneChannel: 65 | timer.Stop() 66 | break 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /cmd/fill.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "github.com/mediocregopher/radix/v3" 7 | "log" 8 | "math/rand" 9 | "strconv" 10 | "time" 11 | 12 | "github.com/spf13/cobra" 13 | ) 14 | 15 | var prefix, count []string 16 | var cycles int 17 | 18 | var fillCmd = &cobra.Command{ 19 | Use: "fill [host:port]", 20 | Short: "Create random keys in redis instance", 21 | Args: cobra.MinimumNArgs(1), 22 | Long: "", 23 | Run: func(cmd *cobra.Command, args []string) { 24 | fmt.Println("Filling redis with random data") 25 | 26 | randomMap, err := createRandomMap(prefix, count) 27 | if err != nil { 28 | log.Fatal(err) 29 | } 30 | 31 | fmt.Println("Random map: ", randomMap) 32 | 33 | pool, err := radix.NewPool("tcp", args[0], 10) 34 | if err != nil { 35 | log.Fatal(err) 36 | } 37 | 38 | rand.Seed(time.Now().UTC().UnixNano()) 39 | 40 | for j := 0; j < cycles; j++ { 41 | for prefix, number := range randomMap { 42 | for i := 0; i < number; i++ { 43 | randVal := strconv.Itoa(rand.Int()) 44 | err = pool.Do(radix.Cmd(nil, "SET", prefix+randVal, randVal)) 45 | if err != nil { 46 | fmt.Println(err) 47 | } 48 | } 49 | } 50 | 51 | fmt.Printf("Cycle %d done\n", j) 52 | } 53 | }, 54 | } 55 | 56 | func createRandomMap(prefix []string, count []string) (map[string]int, error) { 57 | randomMap := make(map[string]int) 58 | for key, val := range prefix { 59 | if key < len(count) { 60 | countForPrefix, err := strconv.Atoi(count[key]) 61 | if err != nil { 62 | return nil, err 63 | } 64 | 65 | if countForPrefix <= 0 { 66 | return nil, errors.New("count cannot be zero or negative") 67 | } 68 | 69 | randomMap[val] = countForPrefix 70 | } else { 71 | randomMap[val] = 1 72 | } 73 | } 74 | 75 | return randomMap, nil 76 | } 77 | 78 | func init() { 79 | rootCmd.AddCommand(fillCmd) 80 | 81 | fillCmd.Flags().StringArrayVar(&prefix, "prefix", []string{"foobar:"}, "Prefixes to fill") 82 | fillCmd.Flags().StringArrayVar(&count, "count", []string{"1"}, "Count of keys to create for prefix in one cycle") 83 | fillCmd.Flags().IntVar(&cycles, "cycles", 1, "Cycles count to perform") 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/scanner/scanner.go: -------------------------------------------------------------------------------- 1 | package scanner 2 | 3 | import ( 4 | "github.com/mediocregopher/radix/v3" 5 | "github.com/obukhov/go-redis-migrate/src/reporter" 6 | "log" 7 | "sync" 8 | ) 9 | 10 | type KeyDump struct { 11 | Key string 12 | Value string 13 | Ttl int 14 | } 15 | 16 | type RedisScannerOpts struct { 17 | Pattern string 18 | ScanCount int 19 | PullRoutineCount int 20 | } 21 | 22 | type RedisScanner struct { 23 | client radix.Client 24 | options RedisScannerOpts 25 | reporter *reporter.Reporter 26 | keyChannel chan string 27 | dumpChannel chan KeyDump 28 | } 29 | 30 | func NewScanner(client radix.Client, options RedisScannerOpts, reporter *reporter.Reporter) *RedisScanner { 31 | return &RedisScanner{ 32 | client: client, 33 | options: options, 34 | reporter: reporter, 35 | dumpChannel: make(chan KeyDump), 36 | keyChannel: make(chan string), 37 | } 38 | } 39 | 40 | func (s *RedisScanner) Start() { 41 | wgPull := new(sync.WaitGroup) 42 | wgPull.Add(s.options.PullRoutineCount) 43 | 44 | go s.scanRoutine() 45 | for i := 0; i < s.options.PullRoutineCount; i++ { 46 | go s.exportRoutine(wgPull) 47 | } 48 | 49 | wgPull.Wait() 50 | close(s.dumpChannel) 51 | } 52 | 53 | func (s *RedisScanner) GetDumpChannel() <-chan KeyDump { 54 | return s.dumpChannel 55 | } 56 | 57 | func (s *RedisScanner) scanRoutine() { 58 | var key string 59 | scanOpts := radix.ScanOpts{ 60 | Command: "SCAN", 61 | Count: s.options.ScanCount, 62 | } 63 | 64 | if s.options.Pattern != "*" { 65 | scanOpts.Pattern = s.options.Pattern 66 | } 67 | 68 | radixScanner := radix.NewScanner(s.client, scanOpts) 69 | for radixScanner.Next(&key) { 70 | s.reporter.AddScannedCounter(1) 71 | s.keyChannel <- key 72 | } 73 | 74 | close(s.keyChannel) 75 | } 76 | 77 | func (s *RedisScanner) exportRoutine(wg *sync.WaitGroup) { 78 | for key := range s.keyChannel { 79 | var value string 80 | var ttl int 81 | 82 | p := radix.Pipeline( 83 | radix.Cmd(&ttl, "PTTL", key), 84 | radix.Cmd(&value, "DUMP", key), 85 | ) 86 | 87 | if err := s.client.Do(p); err != nil { 88 | log.Fatal(err) 89 | } 90 | 91 | if ttl < 0 { 92 | ttl = 0 93 | } 94 | 95 | s.reporter.AddExportedCounter(1) 96 | s.dumpChannel <- KeyDump{ 97 | Key: key, 98 | Ttl: ttl, 99 | Value: value, 100 | } 101 | } 102 | 103 | wg.Done() 104 | } 105 | -------------------------------------------------------------------------------- /cmd/copy.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "github.com/mediocregopher/radix/v3" 6 | "github.com/obukhov/go-redis-migrate/src/pusher" 7 | "github.com/obukhov/go-redis-migrate/src/reporter" 8 | "github.com/obukhov/go-redis-migrate/src/scanner" 9 | "github.com/spf13/cobra" 10 | "log" 11 | "sync" 12 | "time" 13 | ) 14 | 15 | var pattern string 16 | var scanCount, report, exportRoutines, pushRoutines int 17 | 18 | var copyCmd = &cobra.Command{ 19 | Use: "copy ", 20 | Short: "Copy keys from source redis instance to destination by given pattern", 21 | Long: "Copy keys from source redis instance to destination by given pattern and can be provided as just `:` or in Redis URL format: `redis://[:@]:[/]", 22 | Args: cobra.MinimumNArgs(2), 23 | Run: func(cmd *cobra.Command, args []string) { 24 | fmt.Println("Start copying") 25 | 26 | clientSource, err := radix.DefaultClientFunc("tcp", args[0]) 27 | if err != nil { 28 | log.Fatal(err) 29 | } 30 | 31 | clientTarget, err := radix.DefaultClientFunc("tcp", args[1]) 32 | if err != nil { 33 | log.Fatal(err) 34 | } 35 | 36 | statusReporter := reporter.NewReporter() 37 | 38 | redisScanner := scanner.NewScanner( 39 | clientSource, 40 | scanner.RedisScannerOpts{ 41 | Pattern: pattern, 42 | ScanCount: scanCount, 43 | PullRoutineCount: exportRoutines, 44 | }, 45 | statusReporter, 46 | ) 47 | 48 | redisPusher := pusher.NewRedisPusher(clientTarget, redisScanner.GetDumpChannel(), statusReporter) 49 | 50 | waitingGroup := new(sync.WaitGroup) 51 | 52 | statusReporter.Start(time.Second * time.Duration(report)) 53 | redisPusher.Start(waitingGroup, pushRoutines) 54 | redisScanner.Start() 55 | 56 | waitingGroup.Wait() 57 | statusReporter.Stop() 58 | statusReporter.Report() 59 | 60 | fmt.Println("Finish copying") 61 | }, 62 | } 63 | 64 | func init() { 65 | rootCmd.AddCommand(copyCmd) 66 | 67 | copyCmd.Flags().StringVar(&pattern, "pattern", "*", "Match pattern for keys") 68 | copyCmd.Flags().IntVar(&scanCount, "scanCount", 100, "COUNT parameter for redis SCAN command") 69 | copyCmd.Flags().IntVar(&report, "report", 1, "Report current status every N seconds") 70 | copyCmd.Flags().IntVar(&exportRoutines, "exportRoutines", 30, "Number of parallel export goroutines") 71 | copyCmd.Flags().IntVar(&pushRoutines, "pushRoutines", 30, "Number of parallel push goroutines") 72 | } 73 | -------------------------------------------------------------------------------- /cmd/root.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 NAME HERE 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | 21 | homedir "github.com/mitchellh/go-homedir" 22 | "github.com/spf13/cobra" 23 | "github.com/spf13/viper" 24 | ) 25 | 26 | var cfgFile string 27 | 28 | // rootCmd represents the base command when called without any subcommands 29 | var rootCmd = &cobra.Command{ 30 | Use: "go-redis-migrate", 31 | Short: "Application to migrate redis data from one instance to another", 32 | Long: "", 33 | // Uncomment the following line if your bare application 34 | // has an action associated with it: 35 | // Run: func(cmd *cobra.Command, args []string) { }, 36 | } 37 | 38 | // Execute adds all child commands to the root command and sets flags appropriately. 39 | // This is called by main.main(). It only needs to happen once to the rootCmd. 40 | func Execute() { 41 | if err := rootCmd.Execute(); err != nil { 42 | fmt.Println(err) 43 | os.Exit(1) 44 | } 45 | } 46 | 47 | func init() { 48 | cobra.OnInitialize(initConfig) 49 | 50 | // Here you will define your flags and configuration settings. 51 | // Cobra supports persistent flags, which, if defined here, 52 | // will be global for your application. 53 | //rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.go-redis-migrate.yaml)") 54 | 55 | // Cobra also supports local flags, which will only run 56 | // when this action is called directly. 57 | //rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 58 | } 59 | 60 | // initConfig reads in config file and ENV variables if set. 61 | func initConfig() { 62 | if cfgFile != "" { 63 | // Use config file from the flag. 64 | viper.SetConfigFile(cfgFile) 65 | } else { 66 | // Find home directory. 67 | home, err := homedir.Dir() 68 | if err != nil { 69 | fmt.Println(err) 70 | os.Exit(1) 71 | } 72 | 73 | // Search config in home directory with name ".go-redis-migrate" (without extension). 74 | viper.AddConfigPath(home) 75 | viper.SetConfigName(".go-redis-migrate") 76 | } 77 | 78 | viper.AutomaticEnv() // read in environment variables that match 79 | 80 | // If a config file is found, read it in. 81 | if err := viper.ReadInConfig(); err == nil { 82 | fmt.Println("Using config file:", viper.ConfigFileUsed()) 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # go-redis-migrate 2 | 3 | Script to copy data by keys pattern from one redis instance to another. 4 | 5 | ["Copy 1 Million Redis Keys in 2 Minutes with Golang" blog post](https://blog.dclg.net/copy-1-million-redis-keys-in-2-minutes-with-golang) 6 | 7 | ### Usage 8 | 9 | ```bash 10 | go-redis-migrate copy --pattern="prefix:*" 11 | ``` 12 | 13 | *Source*, *destination* - can be provided as just `:` or in Redis URL format: `redis://[:@]:[/]` 14 | *Pattern* - can be glob-style pattern supported by [Redis SCAN](https://redis.io/commands/scan) command. 15 | 16 | Other flags: 17 | ```bash 18 | --report int Report current status every N seconds (default 1) 19 | --scanCount int COUNT parameter for redis SCAN command (default 100) 20 | --exportRoutines int Number of parallel export goroutines (default 30) 21 | --pushRoutines int Number of parallel push goroutines (default 30) 22 | ``` 23 | 24 | ### Installation 25 | 26 | Download the binary for your platform from the [releases page](https://github.com/obukhov/go-redis-migrate/releases). 27 | 28 | ### General idea 29 | 30 | There are 3 main stages of copying keys: 31 | 1. Scanning keys in source 32 | 2. Dumping values and TTLs from source 33 | 3. Restoring values and TTLs in destination 34 | 35 | Scanning is performed with a single goroutine, scanned keys are sent to keys channel (type is chan string). From keys 36 | channel N export goroutines are consuming keys and perform `DUMP` and `PTTL` for them as a pipeline command. Results 37 | are combined in KeyDump structure and transferred to channel of this type. Another M push goroutines are consuming from 38 | the channel and perform `RESTORE` command on the destination instance. 39 | 40 | To guarantee that all keys are exported and restored `sync.WaitingGroup` is used. To monitor current status there is a 41 | separate goroutine that outputs value of atomic counters (for each stage) every K seconds. 42 | 43 | ### Performance tests 44 | 45 | Performed on a laptop with redis instances, running in docker. 46 | 47 | #### Test #1 48 | Source database: 453967 keys. 49 | Keys to copy: 10000 keys. 50 | 51 | | | Version 1.0 (no concurrency) | Version 2.0 (read-write concurrency) | 52 | |----|------------------------------|--------------------------------------| 53 | | #1 | 17.79s | 4.82s | 54 | | #2 | 18.01s | 5.88s | 55 | | #3 | 17.98s | 5.06s | 56 | 57 | #### Test #2 58 | Source database: 453967 keys. 59 | Keys to copy: 367610 keys. 60 | 61 | | | Version 1 (no concurrency) | Version 2.0 (read-write concurrency) | 62 | |----|----------------------------|--------------------------------------| 63 | | #1 | 8m57.98s | 58.78s | 64 | | #2 | 8m44.98s | 55.35s | 65 | | #3 | 8m58.07s | 57.25s | 66 | 67 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= 2 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 3 | github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= 4 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 5 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 6 | github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= 7 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 8 | github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= 9 | github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= 10 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 11 | github.com/joomcode/errorx v0.1.0/go.mod h1:kgco15ekB6cs+4Xjzo7SPeXzx38PbJzBwbnu9qfVNHQ= 12 | github.com/joomcode/redispipe v0.9.0/go.mod h1:4S/gpBCZ62pB/3+XLNWDH7jQnB0vxmpddAMBva2adpM= 13 | github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= 14 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 15 | github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go.mod h1:dSsfyI2zABAdhcbvkXqgxOxrCsbYeHCPgrZkku60dSg= 16 | github.com/mediocregopher/radix/v3 v3.2.0 h1:/Js1JYSq3K34PHTciEm2BDSV0pZZcnKiBXqhN0gPSGk= 17 | github.com/mediocregopher/radix/v3 v3.2.0/go.mod h1:baVzIVpQ8FpvCE6s+XbkoLkBRRI6k/e/HcSNhJDdFjk= 18 | github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= 19 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 20 | github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= 21 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 22 | github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= 23 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 24 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 25 | github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= 26 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 27 | github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= 28 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 29 | github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8= 30 | github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= 31 | github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= 32 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 33 | github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= 34 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 35 | github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38= 36 | github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= 37 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 38 | github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= 39 | github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= 40 | golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 41 | golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a h1:1n5lsVfiQW3yfsRGu98756EH1YthsFqr/5mxHduZW2A= 42 | golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 43 | golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= 44 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 45 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 46 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 47 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright by Aleksandr Obukhov 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------