diff --git a/backup/command.go b/backup/command.go index 53ab503..ba6189d 100644 --- a/backup/command.go +++ b/backup/command.go @@ -15,14 +15,14 @@ type config struct { aclFileName string pathTransform string consulPrefix string - consulConfig *ccns.ConsulConfig + consulConfig *ccns.Config } // Command is a Command implementation that runs the backup operation type Command struct { Self string config *config - consulClient *ccns.ConsulClient + consulClient *ccns.Client pathTransformer *ct.PathTransformer } @@ -35,7 +35,7 @@ func (c *Command) Run(args []string) int { c.config = new(config) // init consul config - c.config.consulConfig = new(ccns.ConsulConfig) + c.config.consulConfig = new(ccns.Config) // setup flags if err = c.setupFlags(args); err != nil { @@ -126,7 +126,7 @@ Options: -ca-cert Optional path to a PEM encoded CA cert file -client-cert Optional path to a PEM encoded client certificate -client-key Optional path to an unencrypted PEM encoded private key - -tls-skip-verify Optional bool for verifying a TLS certificate (not reccomended) + -tls-skip-verify Optional bool for verifying a TLS certificate (not recommended) Please see documentation on GitHub for a detailed explanation of all options. https://github.com/myENA/consul-backinator diff --git a/backup/util.go b/backup/util.go index d74e02b..af45795 100644 --- a/backup/util.go +++ b/backup/util.go @@ -43,7 +43,7 @@ func (c *Command) setupFlags(args []string) error { // fixup prefix per upstream issue 2403 // https://github.com/hashicorp/consul/issues/2403 c.config.consulPrefix = strings.TrimPrefix(c.config.consulPrefix, - ccns.ConsulSeparator) + ccns.Separator) // always okay return nil diff --git a/common/config/defaults.go b/common/config/defaults.go index 72aa431..d9f127c 100644 --- a/common/config/defaults.go +++ b/common/config/defaults.go @@ -6,7 +6,7 @@ import ( ) // AddEnvDefaults attempts to populates missing config information from environment variables -func AddEnvDefaults(consulConfig *ccns.ConsulConfig) { +func AddEnvDefaults(consulConfig *ccns.Config) { // this is used in a few print statements - so we want it populated if consulConfig.Address == "" { consulConfig.Address = os.Getenv("CONSUL_HTTP_ADDR") diff --git a/common/config/flags.go b/common/config/flags.go index 3a899b5..94840f2 100644 --- a/common/config/flags.go +++ b/common/config/flags.go @@ -7,7 +7,7 @@ import ( ) // AddSharedConsulFlags adds flags shared by multiple command implementations -func AddSharedConsulFlags(cmdFlags *flag.FlagSet, consulConfig *ccns.ConsulConfig) { +func AddSharedConsulFlags(cmdFlags *flag.FlagSet, consulConfig *ccns.Config) { // client flags cmdFlags.StringVar(&consulConfig.Address, "addr", "", "Optional consul address and port") @@ -29,5 +29,5 @@ func AddSharedConsulFlags(cmdFlags *flag.FlagSet, consulConfig *ccns.ConsulConfi cmdFlags.StringVar(&consulConfig.TLS.KeyFile, "client-key", "", "Optional path to an unencrypted PEM encoded private key") cmdFlags.BoolVar(&consulConfig.TLS.InsecureSkipVerify, "tls-skip-verify", false, - "Optional bool for verifying a TLS certificate (not reccomended)") + "Optional bool for verifying a TLS certificate (not recommended)") } diff --git a/common/consul/consul.go b/common/consul/consul.go index 30dd7e1..dfc0c6c 100644 --- a/common/consul/consul.go +++ b/common/consul/consul.go @@ -6,25 +6,25 @@ import ( "github.com/hashicorp/go-cleanhttp" ) -// ConsulSeparator is the consul kvp separator -const ConsulSeparator = "/" +// Separator is the consul kvp separator +const Separator = "/" -// ConsulConfig contains consul client configuration and TLSConfig in a single struct -type ConsulConfig struct { +// Config contains consul client configuration and TLSConfig in a single struct +type Config struct { api.Config TLS *api.TLSConfig } -// ConsulClient contains a consul client implementation -type ConsulClient struct { +// Client contains a consul client implementation +type Client struct { *api.Client } // New returns an initialized consul client -func (cc *ConsulConfig) New() (*ConsulClient, error) { - var c *api.Config // upstream client configuration - var client *ConsulClient // client wrapper - var err error // general error holder +func (cc *Config) New() (*Client, error) { + var c *api.Config // upstream client configuration + var client *Client // client wrapper + var err error // general error holder // init upstream config c = api.DefaultConfig() @@ -67,7 +67,7 @@ func (cc *ConsulConfig) New() (*ConsulClient, error) { } // init client wrapper - client = new(ConsulClient) + client = new(Client) client.Client, err = api.NewClient(c) // return client and error diff --git a/common/transformer/transformer.go b/common/transformer/transformer.go index 155215e..0c21d24 100644 --- a/common/transformer/transformer.go +++ b/common/transformer/transformer.go @@ -53,14 +53,14 @@ func (t *PathTransformer) Transform(kvps api.KVPairs) { // split path and key with strings because // the path package will trim a trailing / which // breaks empty folders present in the kvp store - split := strings.Split(kv.Key, ccns.ConsulSeparator) + split := strings.Split(kv.Key, ccns.Separator) // get and check length ... only continue if we actually // have a path we may want to transform if length := len(split); length > 1 { // isolate and replace path - rpath := t.pathReplacer.Replace(strings.Join(split[:length-1], ccns.ConsulSeparator)) + rpath := t.pathReplacer.Replace(strings.Join(split[:length-1], ccns.Separator)) // join replaced path with key - newKey := strings.Join([]string{rpath, split[length-1]}, ccns.ConsulSeparator) + newKey := strings.Join([]string{rpath, split[length-1]}, ccns.Separator) // check keys if kv.Key != newKey { // log change diff --git a/restore/command.go b/restore/command.go index 2fd791d..01f40ce 100644 --- a/restore/command.go +++ b/restore/command.go @@ -16,14 +16,14 @@ type config struct { pathTransform string delTree bool consulPrefix string - consulConfig *ccns.ConsulConfig + consulConfig *ccns.Config } // Command is a Command implementation that runs the backup operation type Command struct { Self string config *config - consulClient *ccns.ConsulClient + consulClient *ccns.Client pathTransformer *ct.PathTransformer } @@ -36,7 +36,7 @@ func (c *Command) Run(args []string) int { c.config = new(config) // init consul config - c.config.consulConfig = new(ccns.ConsulConfig) + c.config.consulConfig = new(ccns.Config) // setup flags if err = c.setupFlags(args); err != nil { @@ -124,7 +124,7 @@ Options: -ca-cert Optional path to a PEM encoded CA cert file -client-cert Optional path to a PEM encoded client certificate -client-key Optional path to an unencrypted PEM encoded private key - -tls-skip-verify Optional bool for verifying a TLS certificate (not reccomended) + -tls-skip-verify Optional bool for verifying a TLS certificate (not recommended) Please see documentation on GitHub for a detailed explanation of all options. https://github.com/myENA/consul-backinator diff --git a/restore/util.go b/restore/util.go index 7e2d46d..138696d 100644 --- a/restore/util.go +++ b/restore/util.go @@ -45,7 +45,7 @@ func (c *Command) setupFlags(args []string) error { // fixup prefix per upstream issue 2403 // https://github.com/hashicorp/consul/issues/2403 c.config.consulPrefix = strings.TrimPrefix(c.config.consulPrefix, - ccns.ConsulSeparator) + ccns.Separator) // always okay return nil