Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisAubuchon committed Feb 10, 2016
1 parent d8978d4 commit 516f57f
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 95 deletions.
92 changes: 46 additions & 46 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,229 +15,229 @@ func init() {
metaPtr := new(command.Meta)
meta := *metaPtr
meta.UI = &cli.BasicUi{
Writer: os.Stdout,
ErrorWriter: os.Stderr,
Writer: os.Stdout,
ErrorWriter: os.Stderr,
}

Commands = map[string]cli.CommandFactory{
"acl-clone": func() (cli.Command, error) {
return &command.ACLCloneCommand{
Meta: meta,
Meta: meta,
}, nil
},
"acl-create": func() (cli.Command, error) {
return &command.ACLCreateCommand{
Meta: meta,
Meta: meta,
}, nil
},
"acl-destroy": func() (cli.Command, error) {
return &command.ACLDestroyCommand{
Meta: meta,
Meta: meta,
}, nil
},
"acl-info": func() (cli.Command, error) {
return &command.ACLInfoCommand{
Meta: meta,
Meta: meta,
}, nil
},
"acl-list": func() (cli.Command, error) {
return &command.ACLListCommand{
Meta: meta,
Meta: meta,
}, nil
},
"acl-update": func() (cli.Command, error) {
return &command.ACLUpdateCommand{
Meta: meta,
Meta: meta,
}, nil
},
"agent-checks": func() (cli.Command, error) {
return &command.AgentChecksCommand{
Meta: meta,
Meta: meta,
}, nil
},
"agent-force-leave": func() (cli.Command, error) {
return &command.AgentForceLeaveCommand{
Meta: meta,
Meta: meta,
}, nil
},
"agent-join": func() (cli.Command, error) {
return &command.AgentJoinCommand{
Meta: meta,
Meta: meta,
}, nil
},
"agent-maintenance": func() (cli.Command, error) {
return &command.AgentMaintenanceCommand{
Meta: meta,
Meta: meta,
}, nil
},
"agent-members": func() (cli.Command, error) {
return &command.AgentMembersCommand{
Meta: meta,
Meta: meta,
}, nil
},
"agent-self": func() (cli.Command, error) {
return &command.AgentSelfCommand{
Meta: meta,
Meta: meta,
}, nil
},
"agent-services": func() (cli.Command, error) {
return &command.AgentServicesCommand{
Meta: meta,
Meta: meta,
}, nil
},
"catalog-datacenters": func() (cli.Command, error) {
return &command.CatalogDatacentersCommand{
Meta: meta,
Meta: meta,
}, nil
},
"catalog-nodes": func() (cli.Command, error) {
return &command.CatalogNodesCommand{
Meta: meta,
Meta: meta,
}, nil
},
"catalog-node": func() (cli.Command, error) {
return &command.CatalogNodeCommand{
Meta: meta,
Meta: meta,
}, nil
},
"catalog-services": func() (cli.Command, error) {
return &command.CatalogServicesCommand{
Meta: meta,
Meta: meta,
}, nil
},
"catalog-service": func() (cli.Command, error) {
return &command.CatalogServiceCommand{
Meta: meta,
Meta: meta,
}, nil
},
"check-fail": func() (cli.Command, error) {
return &command.CheckFailCommand{
Meta: meta,
Meta: meta,
}, nil
},
"check-deregister": func() (cli.Command, error) {
return &command.CheckDeregisterCommand{
Meta: meta,
Meta: meta,
}, nil
},
"check-pass": func() (cli.Command, error) {
return &command.CheckPassCommand{
Meta: meta,
Meta: meta,
}, nil
},
"check-register": func() (cli.Command, error) {
return &command.CheckRegisterCommand{
Meta: meta,
Meta: meta,
}, nil
},
"check-warn": func() (cli.Command, error) {
return &command.CheckWarnCommand{
Meta: meta,
Meta: meta,
}, nil
},
"health-checks": func() (cli.Command, error) {
return &command.HealthChecksCommand{
Meta: meta,
Meta: meta,
}, nil
},
"health-node": func() (cli.Command, error) {
return &command.HealthNodeCommand{
Meta: meta,
Meta: meta,
}, nil
},
"health-service": func() (cli.Command, error) {
return &command.HealthServiceCommand{
Meta: meta,
Meta: meta,
}, nil
},
"health-state": func() (cli.Command, error) {
return &command.HealthStateCommand{
Meta: meta,
Meta: meta,
}, nil
},
"kv-delete": func() (cli.Command, error) {
return &command.KVDeleteCommand{
Meta: meta,
Meta: meta,
}, nil
},
"kv-read": func() (cli.Command, error) {
return &command.KVReadCommand{
Meta: meta,
Meta: meta,
}, nil
},
"kv-watch": func() (cli.Command, error) {
return &command.KVWatchCommand{
Meta: meta,
Meta: meta,
}, nil
},
"kv-write": func() (cli.Command, error) {
return &command.KVWriteCommand{
Meta: meta,
Meta: meta,
}, nil
},
"kv-lock": func() (cli.Command, error) {
return &command.KVLockCommand{
Meta: meta,
Meta: meta,
}, nil
},
"kv-unlock": func() (cli.Command, error) {
return &command.KVUnlockCommand{
Meta: meta,
Meta: meta,
}, nil
},
"service-deregister": func() (cli.Command, error) {
return &command.ServiceDeregisterCommand{
Meta: meta,
Meta: meta,
}, nil
},
"service-maintenance": func() (cli.Command, error) {
return &command.ServiceMaintenanceCommand{
Meta: meta,
Meta: meta,
}, nil
},
"service-register": func() (cli.Command, error) {
return &command.ServiceRegisterCommand{
Meta: meta,
Meta: meta,
}, nil
},
"session-create": func() (cli.Command, error) {
return &command.SessionCreateCommand{
Meta: meta,
Meta: meta,
}, nil
},
"session-destroy": func() (cli.Command, error) {
return &command.SessionDestroyCommand{
Meta: meta,
Meta: meta,
}, nil
},
"session-info": func() (cli.Command, error) {
return &command.SessionInfoCommand{
Meta: meta,
Meta: meta,
}, nil
},
"session-list": func() (cli.Command, error) {
return &command.SessionListCommand{
Meta: meta,
Meta: meta,
}, nil
},
"session-node": func() (cli.Command, error) {
return &command.SessionNodeCommand{
Meta: meta,
Meta: meta,
}, nil
},
"session-renew": func() (cli.Command, error) {
return &command.SessionRenewCommand{
Meta: meta,
Meta: meta,
}, nil
},
"status-leader": func() (cli.Command, error) {
return &command.StatusLeaderCommand{
Meta: meta,
Meta: meta,
}, nil
},
"status-peers": func() (cli.Command, error) {
return &command.StatusPeersCommand{
Meta: meta,
Meta: meta,
}, nil
},
}
Expand Down
48 changes: 25 additions & 23 deletions commands/kv_bulkload.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

type KvBulkloadOptions struct {
Json string
Json string
Prefix string
}

Expand All @@ -22,7 +22,7 @@ func (k *Kv) AddBulkloadSub(cmd *cobra.Command) {
bulkloadCmd := &cobra.Command{
Use: "bulkload",
Short: "Bulkload value to the K/V store",
Long: "Bulkload value to the K/V store",
Long: "Bulkload value to the K/V store",
RunE: func(cmd *cobra.Command, args []string) error {
return k.Bulkload(args, kbo)
},
Expand Down Expand Up @@ -51,10 +51,10 @@ func (k *Kv) Bulkload(args []string, kbo *KvBulkloadOptions) error {
}

kvPairs = flatten(data, kbo.Prefix)
default :
default:
return fmt.Errorf("Must specify --json")
}

client, err := k.KV()
if err != nil {
return err
Expand Down Expand Up @@ -83,29 +83,31 @@ func _flatten(v reflect.Value, prefix string) []*consulapi.KVPair {
}

switch v.Kind() {
case reflect.Map:
for _, k := range v.MapKeys() {
if k.Kind() != reflect.String { continue }
dest = append(dest, _flatten(v.MapIndex(k), path.Join(prefix, k.String()))...)
}
case reflect.Slice:
for k := 0; k < v.Len(); k++ {
dest = append(dest, _flatten(v.Index(k), path.Join(prefix, fmt.Sprintf("%d", k)))...)
}
case reflect.Bool, reflect.Float64, reflect.String:
dest = append(dest, &consulapi.KVPair{
Key: prefix,
case reflect.Map:
for _, k := range v.MapKeys() {
if k.Kind() != reflect.String {
continue
}
dest = append(dest, _flatten(v.MapIndex(k), path.Join(prefix, k.String()))...)
}
case reflect.Slice:
for k := 0; k < v.Len(); k++ {
dest = append(dest, _flatten(v.Index(k), path.Join(prefix, fmt.Sprintf("%d", k)))...)
}
case reflect.Bool, reflect.Float64, reflect.String:
dest = append(dest, &consulapi.KVPair{
Key: prefix,
Value: []byte(fmt.Sprintf("%v", v.Interface())),
})
case reflect.Invalid:
// JSON null
dest = append(dest, &consulapi.KVPair{
Key: prefix,
case reflect.Invalid:
// JSON null
dest = append(dest, &consulapi.KVPair{
Key: prefix,
Value: []byte(fmt.Sprintf("%v", nil)),
})
default:
fmt.Printf("invalid kind: %s\n", v.Kind().String())
}
default:
fmt.Printf("invalid kind: %s\n", v.Kind().String())
}

return dest
}
2 changes: 1 addition & 1 deletion commands/kv_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (k *Kv) AddKeysSub(cmd *cobra.Command) {
keysCmd := &cobra.Command{
Use: "keys <path>",
Short: "List K/V keys",
Long: "List K/V keys",
Long: "List K/V keys",
RunE: func(cmd *cobra.Command, args []string) error {
return k.Keys(args, kko)
},
Expand Down
Loading

0 comments on commit 516f57f

Please sign in to comment.