From ce1ec000cad1e4479697adff8fcd839c0c0b9183 Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Tue, 17 Oct 2017 13:22:23 +0200 Subject: [PATCH] commands: move kv subcommands to subdirs --- command/commands.go | 10 +++++----- command/{kvdel => kv/del}/kv_delete.go | 2 +- command/{kvdel => kv/del}/kv_delete_test.go | 2 +- command/{kvexp => kv/exp}/kv_export.go | 8 ++++---- command/{kvexp => kv/exp}/kv_export_test.go | 6 +++--- command/{kvget => kv/get}/kv_get.go | 2 +- command/{kvget => kv/get}/kv_get_test.go | 2 +- command/{kvimp => kv/imp}/kv_import.go | 6 +++--- command/{kvimp => kv/imp}/kv_import_test.go | 2 +- command/{kvimpexp => kv/impexp}/kvimpexp.go | 2 +- command/{kvput => kv/put}/kv_put.go | 2 +- command/{kvput => kv/put}/kv_put_test.go | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-) rename command/{kvdel => kv/del}/kv_delete.go (99%) rename command/{kvdel => kv/del}/kv_delete_test.go (99%) rename command/{kvexp => kv/exp}/kv_export.go (93%) rename command/{kvexp => kv/exp}/kv_export_test.go (93%) rename command/{kvget => kv/get}/kv_get.go (99%) rename command/{kvget => kv/get}/kv_get_test.go (99%) rename command/{kvimp => kv/imp}/kv_import.go (97%) rename command/{kvimp => kv/imp}/kv_import_test.go (98%) rename command/{kvimpexp => kv/impexp}/kvimpexp.go (95%) rename command/{kvput => kv/put}/kv_put.go (99%) rename command/{kvput => kv/put}/kv_put_test.go (99%) diff --git a/command/commands.go b/command/commands.go index 3f2cb2bb58..607e4dc375 100644 --- a/command/commands.go +++ b/command/commands.go @@ -18,11 +18,11 @@ import ( "github.com/hashicorp/consul/command/keygen" "github.com/hashicorp/consul/command/keyring" "github.com/hashicorp/consul/command/kv" - "github.com/hashicorp/consul/command/kvdel" - "github.com/hashicorp/consul/command/kvexp" - "github.com/hashicorp/consul/command/kvget" - "github.com/hashicorp/consul/command/kvimp" - "github.com/hashicorp/consul/command/kvput" + kvdel "github.com/hashicorp/consul/command/kv/del" + kvexp "github.com/hashicorp/consul/command/kv/exp" + kvget "github.com/hashicorp/consul/command/kv/get" + kvimp "github.com/hashicorp/consul/command/kv/imp" + kvput "github.com/hashicorp/consul/command/kv/put" "github.com/hashicorp/consul/command/leave" "github.com/hashicorp/consul/command/lock" "github.com/hashicorp/consul/command/maint" diff --git a/command/kvdel/kv_delete.go b/command/kv/del/kv_delete.go similarity index 99% rename from command/kvdel/kv_delete.go rename to command/kv/del/kv_delete.go index bb13d27ced..5a26882fd0 100644 --- a/command/kvdel/kv_delete.go +++ b/command/kv/del/kv_delete.go @@ -1,4 +1,4 @@ -package kvdel +package del import ( "flag" diff --git a/command/kvdel/kv_delete_test.go b/command/kv/del/kv_delete_test.go similarity index 99% rename from command/kvdel/kv_delete_test.go rename to command/kv/del/kv_delete_test.go index 7822be31df..10bb296c35 100644 --- a/command/kvdel/kv_delete_test.go +++ b/command/kv/del/kv_delete_test.go @@ -1,4 +1,4 @@ -package kvdel +package del import ( "strconv" diff --git a/command/kvexp/kv_export.go b/command/kv/exp/kv_export.go similarity index 93% rename from command/kvexp/kv_export.go rename to command/kv/exp/kv_export.go index 37ed22df32..e6f7dd793e 100644 --- a/command/kvexp/kv_export.go +++ b/command/kv/exp/kv_export.go @@ -1,4 +1,4 @@ -package kvexp +package exp import ( "encoding/json" @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/command/flags" - "github.com/hashicorp/consul/command/kvimpexp" + "github.com/hashicorp/consul/command/kv/impexp" "github.com/mitchellh/cli" ) @@ -72,9 +72,9 @@ func (c *cmd) Run(args []string) int { return 1 } - exported := make([]*kvimpexp.Entry, len(pairs)) + exported := make([]*impexp.Entry, len(pairs)) for i, pair := range pairs { - exported[i] = kvimpexp.ToEntry(pair) + exported[i] = impexp.ToEntry(pair) } marshaled, err := json.MarshalIndent(exported, "", "\t") diff --git a/command/kvexp/kv_export_test.go b/command/kv/exp/kv_export_test.go similarity index 93% rename from command/kvexp/kv_export_test.go rename to command/kv/exp/kv_export_test.go index 7ebf1f51ba..5a8c6866a4 100644 --- a/command/kvexp/kv_export_test.go +++ b/command/kv/exp/kv_export_test.go @@ -1,4 +1,4 @@ -package kvexp +package exp import ( "encoding/base64" @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/kvimpexp" + "github.com/hashicorp/consul/command/kv/impexp" "github.com/mitchellh/cli" ) @@ -53,7 +53,7 @@ func TestKVExportCommand_Run(t *testing.T) { output := ui.OutputWriter.String() - var exported []*kvimpexp.Entry + var exported []*impexp.Entry err := json.Unmarshal([]byte(output), &exported) if err != nil { t.Fatalf("bad: %d", code) diff --git a/command/kvget/kv_get.go b/command/kv/get/kv_get.go similarity index 99% rename from command/kvget/kv_get.go rename to command/kv/get/kv_get.go index e1ee89b2e3..bcdeb05728 100644 --- a/command/kvget/kv_get.go +++ b/command/kv/get/kv_get.go @@ -1,4 +1,4 @@ -package kvget +package get import ( "bytes" diff --git a/command/kvget/kv_get_test.go b/command/kv/get/kv_get_test.go similarity index 99% rename from command/kvget/kv_get_test.go rename to command/kv/get/kv_get_test.go index d7a9dd9b3c..1c170418c0 100644 --- a/command/kvget/kv_get_test.go +++ b/command/kv/get/kv_get_test.go @@ -1,4 +1,4 @@ -package kvget +package get import ( "encoding/base64" diff --git a/command/kvimp/kv_import.go b/command/kv/imp/kv_import.go similarity index 97% rename from command/kvimp/kv_import.go rename to command/kv/imp/kv_import.go index 7638e358be..4d211cd426 100644 --- a/command/kvimp/kv_import.go +++ b/command/kv/imp/kv_import.go @@ -1,4 +1,4 @@ -package kvimp +package imp import ( "bytes" @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/command/flags" - "github.com/hashicorp/consul/command/kvimpexp" + "github.com/hashicorp/consul/command/kv/impexp" "github.com/mitchellh/cli" ) @@ -61,7 +61,7 @@ func (c *cmd) Run(args []string) int { return 1 } - var entries []*kvimpexp.Entry + var entries []*impexp.Entry if err := json.Unmarshal([]byte(data), &entries); err != nil { c.UI.Error(fmt.Sprintf("Cannot unmarshal data: %s", err)) return 1 diff --git a/command/kvimp/kv_import_test.go b/command/kv/imp/kv_import_test.go similarity index 98% rename from command/kvimp/kv_import_test.go rename to command/kv/imp/kv_import_test.go index e0ae120adc..31e0ffca63 100644 --- a/command/kvimp/kv_import_test.go +++ b/command/kv/imp/kv_import_test.go @@ -1,4 +1,4 @@ -package kvimp +package imp import ( "strings" diff --git a/command/kvimpexp/kvimpexp.go b/command/kv/impexp/kvimpexp.go similarity index 95% rename from command/kvimpexp/kvimpexp.go rename to command/kv/impexp/kvimpexp.go index a865a31013..221d37b2b1 100644 --- a/command/kvimpexp/kvimpexp.go +++ b/command/kv/impexp/kvimpexp.go @@ -1,4 +1,4 @@ -package kvimpexp +package impexp import ( "encoding/base64" diff --git a/command/kvput/kv_put.go b/command/kv/put/kv_put.go similarity index 99% rename from command/kvput/kv_put.go rename to command/kv/put/kv_put.go index 7a529c6085..821ac8bf3c 100644 --- a/command/kvput/kv_put.go +++ b/command/kv/put/kv_put.go @@ -1,4 +1,4 @@ -package kvput +package put import ( "bytes" diff --git a/command/kvput/kv_put_test.go b/command/kv/put/kv_put_test.go similarity index 99% rename from command/kvput/kv_put_test.go rename to command/kv/put/kv_put_test.go index f8644c3a5c..2c21b704fc 100644 --- a/command/kvput/kv_put_test.go +++ b/command/kv/put/kv_put_test.go @@ -1,4 +1,4 @@ -package kvput +package put import ( "bytes"