Skip to content

Commit

Permalink
report card cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronhurt committed Nov 10, 2016
1 parent af2d060 commit 52a9393
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions backup/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backup/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion common/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions common/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)")
}
22 changes: 11 additions & 11 deletions common/consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions common/transformer/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions restore/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion restore/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 52a9393

Please sign in to comment.