Sort default cidrs for reproducible builds

In different distros or environments, we may end up with a different
order of the default string printed during help and man page generation,
So we should sort so the string we print is the same everytime.
This commit is contained in:
Davanum Srinivas 2017-12-10 21:04:44 -05:00
parent bb72237375
commit 62f45189e1

View File

@ -20,6 +20,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"net" "net"
"sort"
"strings" "strings"
"github.com/golang/glog" "github.com/golang/glog"
@ -62,7 +63,9 @@ func init() {
// String is the method to format the flag's value, part of the flag.Value interface. // String is the method to format the flag's value, part of the flag.Value interface.
func (c *cidrs) String() string { func (c *cidrs) String() string {
return strings.Join(c.ipn.StringSlice(), ",") s := c.ipn.StringSlice()
sort.Strings(s)
return strings.Join(s, ",")
} }
// Set supports a value of CSV or the flag repeated multiple times // Set supports a value of CSV or the flag repeated multiple times