From 1c75cf1af53351c98ac30a3844dd83752483e47b Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Sat, 10 Jun 2017 00:28:28 +0200 Subject: [PATCH] pkg refactor command/agent/* -> agent/* command/consul/* -> agent/consul/* command/agent/command{,_test}.go -> command/agent{,_test}.go command/base/command.go -> command/base.go command/base/* -> command/* commands.go -> command/commands.go The script which did the refactor is: ( cd $GOPATH/src/github.com/hashicorp/consul git mv command/agent/command.go command/agent.go git mv command/agent/command_test.go command/agent_test.go git mv command/agent/flag_slice_value{,_test}.go command/ git mv command/agent . git mv command/base/command.go command/base.go git mv command/base/config_util{,_test}.go command/ git mv commands.go command/ git mv consul agent rmdir command/base/ gsed -i -e 's|package agent|package command|' command/agent{,_test}.go gsed -i -e 's|package agent|package command|' command/flag_slice_value{,_test}.go gsed -i -e 's|package base|package command|' command/base.go command/config_util{,_test}.go gsed -i -e 's|package main|package command|' command/commands.go gsed -i -e 's|base.Command|BaseCommand|' command/commands.go gsed -i -e 's|agent.Command|AgentCommand|' command/commands.go gsed -i -e 's|\tCommand:|\tBaseCommand:|' command/commands.go gsed -i -e 's|base\.||' command/commands.go gsed -i -e 's|command\.||' command/commands.go gsed -i -e 's|command|c|' main.go gsed -i -e 's|range Commands|range command.Commands|' main.go gsed -i -e 's|Commands: Commands|Commands: command.Commands|' main.go gsed -i -e 's|base\.BoolValue|BoolValue|' command/operator_autopilot_set.go gsed -i -e 's|base\.DurationValue|DurationValue|' command/operator_autopilot_set.go gsed -i -e 's|base\.StringValue|StringValue|' command/operator_autopilot_set.go gsed -i -e 's|base\.UintValue|UintValue|' command/operator_autopilot_set.go gsed -i -e 's|\bCommand\b|BaseCommand|' command/base.go gsed -i -e 's|BaseCommand Options|Command Options|' command/base.go gsed -i -e 's|base.Command|BaseCommand|' command/*.go gsed -i -e 's|c\.Command|c.BaseCommand|g' command/*.go gsed -i -e 's|\tCommand:|\tBaseCommand:|' command/*_test.go gsed -i -e 's|base\.||' command/*_test.go gsed -i -e 's|\bCommand\b|AgentCommand|' command/agent{,_test}.go gsed -i -e 's|cmd.AgentCommand|cmd.BaseCommand|' command/agent.go gsed -i -e 's|cli.AgentCommand = new(Command)|cli.Command = new(AgentCommand)|' command/agent_test.go gsed -i -e 's|exec.AgentCommand|exec.Command|' command/agent_test.go gsed -i -e 's|exec.BaseCommand|exec.Command|' command/agent_test.go gsed -i -e 's|NewTestAgent|agent.NewTestAgent|' command/agent_test.go gsed -i -e 's|= TestConfig|= agent.TestConfig|' command/agent_test.go gsed -i -e 's|: RetryJoin|: agent.RetryJoin|' command/agent_test.go gsed -i -e 's|\.\./\.\./|../|' command/config_util_test.go gsed -i -e 's|\bverifyUniqueListeners|VerifyUniqueListeners|' agent/config{,_test}.go command/agent.go gsed -i -e 's|\bserfLANKeyring\b|SerfLANKeyring|g' agent/{agent,keyring,testagent}.go command/agent.go gsed -i -e 's|\bserfWANKeyring\b|SerfWANKeyring|g' agent/{agent,keyring,testagent}.go command/agent.go gsed -i -e 's|\bNewAgent\b|agent.New|g' command/agent{,_test}.go gsed -i -e 's|\bNewAgent|New|' agent/{acl_test,agent,testagent}.go gsed -i -e 's|\bAgent\b|agent.&|g' command/agent{,_test}.go gsed -i -e 's|\bBool\b|agent.&|g' command/agent{,_test}.go gsed -i -e 's|\bConfig\b|agent.&|g' command/agent{,_test}.go gsed -i -e 's|\bDefaultConfig\b|agent.&|g' command/agent{,_test}.go gsed -i -e 's|\bDevConfig\b|agent.&|g' command/agent{,_test}.go gsed -i -e 's|\bMergeConfig\b|agent.&|g' command/agent{,_test}.go gsed -i -e 's|\bReadConfigPaths\b|agent.&|g' command/agent{,_test}.go gsed -i -e 's|\bParseMetaPair\b|agent.&|g' command/agent{,_test}.go gsed -i -e 's|\bSerfLANKeyring\b|agent.&|g' command/agent{,_test}.go gsed -i -e 's|\bSerfWANKeyring\b|agent.&|g' command/agent{,_test}.go gsed -i -e 's|circonus\.agent|circonus|g' command/agent{,_test}.go gsed -i -e 's|logger\.agent|logger|g' command/agent{,_test}.go gsed -i -e 's|metrics\.agent|metrics|g' command/agent{,_test}.go gsed -i -e 's|// agent.Agent|// agent|' command/agent{,_test}.go gsed -i -e 's|a\.agent\.Config|a.Config|' command/agent{,_test}.go gsed -i -e 's|agent\.AppendSliceValue|AppendSliceValue|' command/{configtest,validate}.go gsed -i -e 's|consul/consul|agent/consul|' GNUmakefile gsed -i -e 's|\.\./test|../../test|' agent/consul/server_test.go # fix imports f=$(grep -rl 'github.com/hashicorp/consul/command/agent' * | grep '\.go') gsed -i -e 's|github.com/hashicorp/consul/command/agent|github.com/hashicorp/consul/agent|' $f goimports -w $f f=$(grep -rl 'github.com/hashicorp/consul/consul' * | grep '\.go') gsed -i -e 's|github.com/hashicorp/consul/consul|github.com/hashicorp/consul/agent/consul|' $f goimports -w $f goimports -w command/*.go main.go ) --- GNUmakefile | 4 +- {command/agent => agent}/acl.go | 2 +- {command/agent => agent}/acl_endpoint.go | 2 +- {command/agent => agent}/acl_endpoint_test.go | 2 +- {command/agent => agent}/acl_test.go | 4 +- {command/agent => agent}/agent.go | 12 +- {command/agent => agent}/agent_endpoint.go | 2 +- .../agent => agent}/agent_endpoint_test.go | 2 +- {command/agent => agent}/agent_test.go | 4 +- {command/agent => agent}/bindata_assetfs.go | 0 {command/agent => agent}/catalog_endpoint.go | 2 +- .../agent => agent}/catalog_endpoint_test.go | 2 +- {command/agent => agent}/check.go | 2 +- {command/agent => agent}/check_test.go | 2 +- {command/agent => agent}/config.go | 6 +- {command/agent => agent}/config_aws.go | 0 {command/agent => agent}/config_azure.go | 0 {command/agent => agent}/config_azure_test.go | 0 {command/agent => agent}/config_ec2_test.go | 0 {command/agent => agent}/config_gce.go | 0 {command/agent => agent}/config_gce_test.go | 0 {command/agent => agent}/config_test.go | 2 +- {consul => agent/consul}/acl.go | 2 +- {consul => agent/consul}/acl_endpoint.go | 4 +- {consul => agent/consul}/acl_endpoint_test.go | 2 +- {consul => agent/consul}/acl_replication.go | 2 +- .../consul}/acl_replication_test.go | 2 +- {consul => agent/consul}/acl_test.go | 2 +- {consul => agent/consul}/agent/server.go | 0 .../consul}/agent/server_internal_test.go | 0 {consul => agent/consul}/agent/server_test.go | 2 +- {consul => agent/consul}/autopilot.go | 4 +- {consul => agent/consul}/autopilot_test.go | 0 {consul => agent/consul}/catalog_endpoint.go | 4 +- .../consul}/catalog_endpoint_test.go | 2 +- {consul => agent/consul}/client.go | 6 +- {consul => agent/consul}/client_test.go | 2 +- {consul => agent/consul}/config.go | 2 +- {consul => agent/consul}/config_test.go | 0 .../consul}/coordinate_endpoint.go | 4 +- .../consul}/coordinate_endpoint_test.go | 2 +- {consul => agent/consul}/filter.go | 2 +- {consul => agent/consul}/filter_test.go | 2 +- {consul => agent/consul}/flood.go | 2 +- {consul => agent/consul}/fsm.go | 4 +- {consul => agent/consul}/fsm_test.go | 4 +- {consul => agent/consul}/health_endpoint.go | 4 +- .../consul}/health_endpoint_test.go | 2 +- {consul => agent/consul}/helper_test.go | 0 {consul => agent/consul}/internal_endpoint.go | 4 +- .../consul}/internal_endpoint_test.go | 2 +- {consul => agent/consul}/issue_test.go | 2 +- {consul => agent/consul}/kvs_endpoint.go | 4 +- {consul => agent/consul}/kvs_endpoint_test.go | 2 +- {consul => agent/consul}/leader.go | 4 +- {consul => agent/consul}/leader_test.go | 2 +- {consul => agent/consul}/merge.go | 2 +- {consul => agent/consul}/merge_test.go | 0 .../consul}/operator_autopilot_endpoint.go | 2 +- .../operator_autopilot_endpoint_test.go | 2 +- {consul => agent/consul}/operator_endpoint.go | 0 .../consul}/operator_raft_endpoint.go | 4 +- .../consul}/operator_raft_endpoint_test.go | 2 +- {consul => agent/consul}/pool.go | 2 +- .../consul}/prepared_query/template.go | 2 +- .../consul}/prepared_query/template_test.go | 2 +- .../consul}/prepared_query/walk.go | 0 .../consul}/prepared_query/walk_test.go | 3 +- .../consul}/prepared_query_endpoint.go | 4 +- .../consul}/prepared_query_endpoint_test.go | 2 +- {consul => agent/consul}/raft_rpc.go | 0 {consul => agent/consul}/rpc.go | 6 +- {consul => agent/consul}/rpc_test.go | 4 +- {consul => agent/consul}/rtt.go | 2 +- {consul => agent/consul}/rtt_test.go | 2 +- {consul => agent/consul}/serf.go | 2 +- {consul => agent/consul}/serf_test.go | 0 {consul => agent/consul}/server.go | 8 +- {consul => agent/consul}/server_test.go | 32 +-- {consul => agent/consul}/servers/manager.go | 2 +- .../consul}/servers/manager_internal_test.go | 2 +- .../consul}/servers/manager_test.go | 4 +- {consul => agent/consul}/servers/router.go | 4 +- .../consul}/servers/router_test.go | 2 +- .../consul}/servers/serf_adapter.go | 2 +- .../consul}/servers/serf_flooder.go | 2 +- {consul => agent/consul}/session_endpoint.go | 4 +- .../consul}/session_endpoint_test.go | 2 +- {consul => agent/consul}/session_ttl.go | 2 +- {consul => agent/consul}/session_ttl_test.go | 2 +- {consul => agent/consul}/snapshot_endpoint.go | 2 +- .../consul}/snapshot_endpoint_test.go | 2 +- {consul => agent/consul}/state/acl.go | 2 +- {consul => agent/consul}/state/acl_test.go | 2 +- {consul => agent/consul}/state/autopilot.go | 2 +- .../consul}/state/autopilot_test.go | 2 +- {consul => agent/consul}/state/catalog.go | 2 +- .../consul}/state/catalog_test.go | 2 +- {consul => agent/consul}/state/coordinate.go | 2 +- .../consul}/state/coordinate_test.go | 2 +- {consul => agent/consul}/state/delay.go | 0 {consul => agent/consul}/state/delay_test.go | 0 {consul => agent/consul}/state/graveyard.go | 0 .../consul}/state/graveyard_test.go | 0 {consul => agent/consul}/state/kvs.go | 2 +- {consul => agent/consul}/state/kvs_test.go | 2 +- {consul => agent/consul}/state/notify.go | 0 {consul => agent/consul}/state/notify_test.go | 0 .../consul}/state/prepared_query.go | 4 +- .../consul}/state/prepared_query_index.go | 2 +- .../state/prepared_query_index_test.go | 2 +- .../consul}/state/prepared_query_test.go | 2 +- {consul => agent/consul}/state/schema.go | 0 {consul => agent/consul}/state/schema_test.go | 0 {consul => agent/consul}/state/session.go | 2 +- .../consul}/state/session_test.go | 2 +- {consul => agent/consul}/state/state_store.go | 0 .../consul}/state/state_store_test.go | 2 +- .../consul}/state/tombstone_gc.go | 0 .../consul}/state/tombstone_gc_test.go | 0 {consul => agent/consul}/state/txn.go | 2 +- {consul => agent/consul}/state/txn_test.go | 2 +- {consul => agent/consul}/stats_fetcher.go | 4 +- .../consul}/stats_fetcher_test.go | 2 +- {consul => agent/consul}/status_endpoint.go | 2 +- .../consul}/status_endpoint_test.go | 0 {consul => agent/consul}/structs/operator.go | 0 .../consul}/structs/operator_test.go | 0 .../consul}/structs/prepared_query.go | 0 .../consul}/structs/prepared_query_test.go | 0 {consul => agent/consul}/structs/snapshot.go | 0 {consul => agent/consul}/structs/structs.go | 0 .../consul}/structs/structs_test.go | 0 {consul => agent/consul}/structs/txn.go | 0 {consul => agent/consul}/txn_endpoint.go | 2 +- {consul => agent/consul}/txn_endpoint_test.go | 2 +- {consul => agent/consul}/util.go | 2 +- {consul => agent/consul}/util_test.go | 0 .../agent => agent}/coordinate_endpoint.go | 2 +- .../coordinate_endpoint_test.go | 2 +- {command/agent => agent}/dns.go | 4 +- {command/agent => agent}/dns_test.go | 2 +- {command/agent => agent}/event_endpoint.go | 2 +- .../agent => agent}/event_endpoint_test.go | 2 +- {command/agent => agent}/health_endpoint.go | 2 +- .../agent => agent}/health_endpoint_test.go | 2 +- {command/agent => agent}/http.go | 2 +- {command/agent => agent}/http_test.go | 2 +- {command/agent => agent}/keyring.go | 8 +- {command/agent => agent}/keyring_test.go | 0 {command/agent => agent}/kvs_endpoint.go | 2 +- {command/agent => agent}/kvs_endpoint_test.go | 2 +- {command/agent => agent}/local.go | 4 +- {command/agent => agent}/local_test.go | 2 +- {command/agent => agent}/mock/notify.go | 0 {command/agent => agent}/operator_endpoint.go | 2 +- .../agent => agent}/operator_endpoint_test.go | 2 +- .../prepared_query_endpoint.go | 4 +- .../prepared_query_endpoint_test.go | 2 +- {command/agent => agent}/remote_exec.go | 2 +- {command/agent => agent}/remote_exec_test.go | 2 +- {command/agent => agent}/retry_join.go | 0 {command/agent => agent}/session_endpoint.go | 4 +- .../agent => agent}/session_endpoint_test.go | 4 +- {command/agent => agent}/snapshot_endpoint.go | 2 +- .../agent => agent}/snapshot_endpoint_test.go | 0 {command/agent => agent}/status_endpoint.go | 0 .../agent => agent}/status_endpoint_test.go | 0 {command/agent => agent}/structs.go | 2 +- {command/agent => agent}/structs_test.go | 0 {command/agent => agent}/testagent.go | 10 +- {command/agent => agent}/translate_addr.go | 2 +- {command/agent => agent}/txn_endpoint.go | 2 +- {command/agent => agent}/txn_endpoint_test.go | 2 +- {command/agent => agent}/ui_endpoint.go | 2 +- {command/agent => agent}/ui_endpoint_test.go | 2 +- {command/agent => agent}/user_event.go | 2 +- {command/agent => agent}/user_event_test.go | 2 +- {command/agent => agent}/util.go | 0 {command/agent => agent}/util_test.go | 0 {command/agent => agent}/watch_handler.go | 0 .../agent => agent}/watch_handler_test.go | 0 command/{agent/command.go => agent.go} | 78 +++---- .../{agent/command_test.go => agent_test.go} | 84 +++---- command/{base/command.go => base.go} | 32 +-- commands.go => command/commands.go | 213 +++++++++--------- command/{base => }/config_util.go | 2 +- command/{base => }/config_util_test.go | 7 +- command/configtest.go | 15 +- command/configtest_test.go | 5 +- command/event.go | 11 +- command/event_test.go | 7 +- command/exec.go | 15 +- command/exec_test.go | 7 +- command/{agent => }/flag_slice_value.go | 2 +- command/{agent => }/flag_slice_value_test.go | 2 +- command/force_leave.go | 11 +- command/force_leave_test.go | 7 +- command/info.go | 12 +- command/info_test.go | 7 +- command/join.go | 11 +- command/join_test.go | 7 +- command/keygen.go | 10 +- command/keygen_test.go | 5 +- command/keyring.go | 13 +- command/keyring_test.go | 7 +- command/kv_command.go | 3 +- command/kv_delete.go | 11 +- command/kv_delete_test.go | 7 +- command/kv_export.go | 13 +- command/kv_export_test.go | 7 +- command/kv_get.go | 17 +- command/kv_get_test.go | 7 +- command/kv_import.go | 11 +- command/kv_import_test.go | 7 +- command/kv_put.go | 11 +- command/kv_put_test.go | 7 +- command/leave.go | 11 +- command/leave_test.go | 7 +- command/lock.go | 13 +- command/lock_test.go | 7 +- command/maint.go | 12 +- command/maint_test.go | 9 +- command/members.go | 11 +- command/members_test.go | 7 +- command/monitor.go | 12 +- command/operator.go | 3 +- command/operator_autopilot.go | 3 +- command/operator_autopilot_get.go | 13 +- command/operator_autopilot_get_test.go | 7 +- command/operator_autopilot_set.go | 23 +- command/operator_autopilot_set_test.go | 9 +- command/operator_raft.go | 14 +- command/operator_raft_list.go | 13 +- command/operator_raft_list_test.go | 7 +- command/operator_raft_remove.go | 11 +- command/operator_raft_remove_test.go | 11 +- command/operator_raft_test.go | 5 +- command/reload.go | 11 +- command/reload_test.go | 7 +- command/rtt.go | 11 +- command/rtt_test.go | 9 +- command/snapshot_inspect.go | 7 +- command/snapshot_inspect_test.go | 7 +- command/snapshot_restore.go | 12 +- command/snapshot_restore_test.go | 7 +- command/snapshot_save.go | 13 +- command/snapshot_save_test.go | 7 +- command/validate.go | 17 +- command/validate_test.go | 5 +- command/version.go | 4 +- command/watch.go | 27 ++- command/watch_test.go | 7 +- main.go | 13 +- testrpc/wait.go | 2 +- 255 files changed, 684 insertions(+), 752 deletions(-) rename {command/agent => agent}/acl.go (99%) rename {command/agent => agent}/acl_endpoint.go (99%) rename {command/agent => agent}/acl_endpoint_test.go (99%) rename {command/agent => agent}/acl_test.go (99%) rename {command/agent => agent}/agent.go (99%) rename {command/agent => agent}/agent_endpoint.go (99%) rename {command/agent => agent}/agent_endpoint_test.go (99%) rename {command/agent => agent}/agent_test.go (99%) rename {command/agent => agent}/bindata_assetfs.go (100%) rename {command/agent => agent}/catalog_endpoint.go (98%) rename {command/agent => agent}/catalog_endpoint_test.go (99%) rename {command/agent => agent}/check.go (99%) rename {command/agent => agent}/check_test.go (99%) rename {command/agent => agent}/config.go (99%) rename {command/agent => agent}/config_aws.go (100%) rename {command/agent => agent}/config_azure.go (100%) rename {command/agent => agent}/config_azure_test.go (100%) rename {command/agent => agent}/config_ec2_test.go (100%) rename {command/agent => agent}/config_gce.go (100%) rename {command/agent => agent}/config_gce_test.go (100%) rename {command/agent => agent}/config_test.go (99%) rename {consul => agent/consul}/acl.go (99%) rename {consul => agent/consul}/acl_endpoint.go (98%) rename {consul => agent/consul}/acl_endpoint_test.go (99%) rename {consul => agent/consul}/acl_replication.go (99%) rename {consul => agent/consul}/acl_replication_test.go (99%) rename {consul => agent/consul}/acl_test.go (99%) rename {consul => agent/consul}/agent/server.go (100%) rename {consul => agent/consul}/agent/server_internal_test.go (100%) rename {consul => agent/consul}/agent/server_test.go (98%) rename {consul => agent/consul}/autopilot.go (99%) rename {consul => agent/consul}/autopilot_test.go (100%) rename {consul => agent/consul}/catalog_endpoint.go (98%) rename {consul => agent/consul}/catalog_endpoint_test.go (99%) rename {consul => agent/consul}/client.go (98%) rename {consul => agent/consul}/client_test.go (99%) rename {consul => agent/consul}/config.go (99%) rename {consul => agent/consul}/config_test.go (100%) rename {consul => agent/consul}/coordinate_endpoint.go (98%) rename {consul => agent/consul}/coordinate_endpoint_test.go (99%) rename {consul => agent/consul}/filter.go (97%) rename {consul => agent/consul}/filter_test.go (98%) rename {consul => agent/consul}/flood.go (96%) rename {consul => agent/consul}/fsm.go (99%) rename {consul => agent/consul}/fsm_test.go (99%) rename {consul => agent/consul}/health_endpoint.go (97%) rename {consul => agent/consul}/health_endpoint_test.go (99%) rename {consul => agent/consul}/helper_test.go (100%) rename {consul => agent/consul}/internal_endpoint.go (97%) rename {consul => agent/consul}/internal_endpoint_test.go (99%) rename {consul => agent/consul}/issue_test.go (96%) rename {consul => agent/consul}/kvs_endpoint.go (98%) rename {consul => agent/consul}/kvs_endpoint_test.go (99%) rename {consul => agent/consul}/leader.go (99%) rename {consul => agent/consul}/leader_test.go (99%) rename {consul => agent/consul}/merge.go (97%) rename {consul => agent/consul}/merge_test.go (100%) rename {consul => agent/consul}/operator_autopilot_endpoint.go (98%) rename {consul => agent/consul}/operator_autopilot_endpoint_test.go (99%) rename {consul => agent/consul}/operator_endpoint.go (100%) rename {consul => agent/consul}/operator_raft_endpoint.go (98%) rename {consul => agent/consul}/operator_raft_endpoint_test.go (99%) rename {consul => agent/consul}/pool.go (99%) rename {consul => agent/consul}/prepared_query/template.go (98%) rename {consul => agent/consul}/prepared_query/template_test.go (99%) rename {consul => agent/consul}/prepared_query/walk.go (100%) rename {consul => agent/consul}/prepared_query/walk_test.go (95%) rename {consul => agent/consul}/prepared_query_endpoint.go (99%) rename {consul => agent/consul}/prepared_query_endpoint_test.go (99%) rename {consul => agent/consul}/raft_rpc.go (100%) rename {consul => agent/consul}/rpc.go (98%) rename {consul => agent/consul}/rpc_test.go (97%) rename {consul => agent/consul}/rtt.go (99%) rename {consul => agent/consul}/rtt_test.go (99%) rename {consul => agent/consul}/serf.go (99%) rename {consul => agent/consul}/serf_test.go (100%) rename {consul => agent/consul}/server.go (99%) rename {consul => agent/consul}/server_test.go (95%) rename {consul => agent/consul}/servers/manager.go (99%) rename {consul => agent/consul}/servers/manager_internal_test.go (99%) rename {consul => agent/consul}/servers/manager_test.go (98%) rename {consul => agent/consul}/servers/router.go (99%) rename {consul => agent/consul}/servers/router_test.go (99%) rename {consul => agent/consul}/servers/serf_adapter.go (97%) rename {consul => agent/consul}/servers/serf_flooder.go (98%) rename {consul => agent/consul}/session_endpoint.go (98%) rename {consul => agent/consul}/session_endpoint_test.go (99%) rename {consul => agent/consul}/session_ttl.go (98%) rename {consul => agent/consul}/session_ttl_test.go (99%) rename {consul => agent/consul}/snapshot_endpoint.go (99%) rename {consul => agent/consul}/snapshot_endpoint_test.go (99%) rename {consul => agent/consul}/state/acl.go (98%) rename {consul => agent/consul}/state/acl_test.go (99%) rename {consul => agent/consul}/state/autopilot.go (98%) rename {consul => agent/consul}/state/autopilot_test.go (97%) rename {consul => agent/consul}/state/catalog.go (99%) rename {consul => agent/consul}/state/catalog_test.go (99%) rename {consul => agent/consul}/state/coordinate.go (98%) rename {consul => agent/consul}/state/coordinate_test.go (99%) rename {consul => agent/consul}/state/delay.go (100%) rename {consul => agent/consul}/state/delay_test.go (100%) rename {consul => agent/consul}/state/graveyard.go (100%) rename {consul => agent/consul}/state/graveyard_test.go (100%) rename {consul => agent/consul}/state/kvs.go (99%) rename {consul => agent/consul}/state/kvs_test.go (99%) rename {consul => agent/consul}/state/notify.go (100%) rename {consul => agent/consul}/state/notify_test.go (100%) rename {consul => agent/consul}/state/prepared_query.go (99%) rename {consul => agent/consul}/state/prepared_query_index.go (96%) rename {consul => agent/consul}/state/prepared_query_index_test.go (98%) rename {consul => agent/consul}/state/prepared_query_test.go (99%) rename {consul => agent/consul}/state/schema.go (100%) rename {consul => agent/consul}/state/schema_test.go (100%) rename {consul => agent/consul}/state/session.go (99%) rename {consul => agent/consul}/state/session_test.go (99%) rename {consul => agent/consul}/state/state_store.go (100%) rename {consul => agent/consul}/state/state_store_test.go (98%) rename {consul => agent/consul}/state/tombstone_gc.go (100%) rename {consul => agent/consul}/state/tombstone_gc_test.go (100%) rename {consul => agent/consul}/state/txn.go (98%) rename {consul => agent/consul}/state/txn_test.go (99%) rename {consul => agent/consul}/stats_fetcher.go (96%) rename {consul => agent/consul}/stats_fetcher_test.go (97%) rename {consul => agent/consul}/status_endpoint.go (96%) rename {consul => agent/consul}/status_endpoint_test.go (100%) rename {consul => agent/consul}/structs/operator.go (100%) rename {consul => agent/consul}/structs/operator_test.go (100%) rename {consul => agent/consul}/structs/prepared_query.go (100%) rename {consul => agent/consul}/structs/prepared_query_test.go (100%) rename {consul => agent/consul}/structs/snapshot.go (100%) rename {consul => agent/consul}/structs/structs.go (100%) rename {consul => agent/consul}/structs/structs_test.go (100%) rename {consul => agent/consul}/structs/txn.go (100%) rename {consul => agent/consul}/txn_endpoint.go (98%) rename {consul => agent/consul}/txn_endpoint_test.go (99%) rename {consul => agent/consul}/util.go (99%) rename {consul => agent/consul}/util_test.go (100%) rename {command/agent => agent}/coordinate_endpoint.go (97%) rename {command/agent => agent}/coordinate_endpoint_test.go (97%) rename {command/agent => agent}/dns.go (99%) rename {command/agent => agent}/dns_test.go (99%) rename {command/agent => agent}/event_endpoint.go (98%) rename {command/agent => agent}/event_endpoint_test.go (99%) rename {command/agent => agent}/health_endpoint.go (99%) rename {command/agent => agent}/health_endpoint_test.go (99%) rename {command/agent => agent}/http.go (99%) rename {command/agent => agent}/http_test.go (99%) rename {command/agent => agent}/keyring.go (96%) rename {command/agent => agent}/keyring_test.go (100%) rename {command/agent => agent}/kvs_endpoint.go (99%) rename {command/agent => agent}/kvs_endpoint_test.go (99%) rename {command/agent => agent}/local.go (99%) rename {command/agent => agent}/local_test.go (99%) rename {command/agent => agent}/mock/notify.go (100%) rename {command/agent => agent}/operator_endpoint.go (99%) rename {command/agent => agent}/operator_endpoint_test.go (99%) rename {command/agent => agent}/prepared_query_endpoint.go (98%) rename {command/agent => agent}/prepared_query_endpoint_test.go (99%) rename {command/agent => agent}/remote_exec.go (99%) rename {command/agent => agent}/remote_exec_test.go (99%) rename {command/agent => agent}/retry_join.go (100%) rename {command/agent => agent}/session_endpoint.go (98%) rename {command/agent => agent}/session_endpoint_test.go (99%) rename {command/agent => agent}/snapshot_endpoint.go (95%) rename {command/agent => agent}/snapshot_endpoint_test.go (100%) rename {command/agent => agent}/status_endpoint.go (100%) rename {command/agent => agent}/status_endpoint_test.go (100%) rename {command/agent => agent}/structs.go (98%) rename {command/agent => agent}/structs_test.go (100%) rename {command/agent => agent}/testagent.go (97%) rename {command/agent => agent}/translate_addr.go (97%) rename {command/agent => agent}/txn_endpoint.go (99%) rename {command/agent => agent}/txn_endpoint_test.go (99%) rename {command/agent => agent}/ui_endpoint.go (98%) rename {command/agent => agent}/ui_endpoint_test.go (99%) rename {command/agent => agent}/user_event.go (99%) rename {command/agent => agent}/user_event_test.go (98%) rename {command/agent => agent}/util.go (100%) rename {command/agent => agent}/util_test.go (100%) rename {command/agent => agent}/watch_handler.go (100%) rename {command/agent => agent}/watch_handler_test.go (100%) rename command/{agent/command.go => agent.go} (92%) rename command/{agent/command_test.go => agent_test.go} (86%) rename command/{base/command.go => base.go} (90%) rename commands.go => command/commands.go (55%) rename command/{base => }/config_util.go (99%) rename command/{base => }/config_util_test.go (97%) rename command/{agent => }/flag_slice_value.go (96%) rename command/{agent => }/flag_slice_value_test.go (97%) diff --git a/GNUmakefile b/GNUmakefile index 5333ffaaf4..35958be973 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -48,8 +48,8 @@ cov: test: dev go test -tags "$(GOTAGS)" -i -run '^$$' ./... - go test -tags "$(GOTAGS)" -v $$(go list ./... | egrep -v '(consul/consul|vendor)') > test.log 2>&1 || echo 'FAIL_TOKEN' >> test.log - go test -tags "$(GOTAGS)" -v $$(go list ./... | egrep '(consul/consul)') >> test.log 2>&1 || echo 'FAIL_TOKEN' >> test.log + go test -tags "$(GOTAGS)" -v $$(go list ./... | egrep -v '(agent/consul|vendor)') > test.log 2>&1 || echo 'FAIL_TOKEN' >> test.log + go test -tags "$(GOTAGS)" -v $$(go list ./... | egrep '(agent/consul)') >> test.log 2>&1 || echo 'FAIL_TOKEN' >> test.log @if [ "$$TRAVIS" == "true" ] ; then cat test.log ; fi @if grep -q 'FAIL_TOKEN' test.log ; then grep 'FAIL:' test.log ; exit 1 ; else echo 'PASS' ; fi diff --git a/command/agent/acl.go b/agent/acl.go similarity index 99% rename from command/agent/acl.go rename to agent/acl.go index d62e49cce4..01007a37c8 100644 --- a/command/agent/acl.go +++ b/agent/acl.go @@ -9,7 +9,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/types" "github.com/hashicorp/golang-lru" "github.com/hashicorp/serf/serf" diff --git a/command/agent/acl_endpoint.go b/agent/acl_endpoint.go similarity index 99% rename from command/agent/acl_endpoint.go rename to agent/acl_endpoint.go index 5f3dd65e13..9d217764dd 100644 --- a/command/agent/acl_endpoint.go +++ b/agent/acl_endpoint.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) // aclCreateResponse is used to wrap the ACL ID diff --git a/command/agent/acl_endpoint_test.go b/agent/acl_endpoint_test.go similarity index 99% rename from command/agent/acl_endpoint_test.go rename to agent/acl_endpoint_test.go index 526c01bdf8..915d22cb3c 100644 --- a/command/agent/acl_endpoint_test.go +++ b/agent/acl_endpoint_test.go @@ -7,7 +7,7 @@ import ( "net/http/httptest" "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) func makeTestACL(t *testing.T, srv *HTTPServer) string { diff --git a/command/agent/acl_test.go b/agent/acl_test.go similarity index 99% rename from command/agent/acl_test.go rename to agent/acl_test.go index 5c28921f6e..59bf99b1a7 100644 --- a/command/agent/acl_test.go +++ b/agent/acl_test.go @@ -8,7 +8,7 @@ import ( "time" rawacl "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/consul/types" "github.com/hashicorp/serf/serf" @@ -22,7 +22,7 @@ func TestACL_Bad_Config(t *testing.T) { // do not use TestAgent here since we want // the agent to fail during startup. - _, err := NewAgent(cfg) + _, err := New(cfg) if err == nil || !strings.Contains(err.Error(), "invalid ACL down policy") { t.Fatalf("err: %v", err) } diff --git a/command/agent/agent.go b/agent/agent.go similarity index 99% rename from command/agent/agent.go rename to agent/agent.go index 85ee5514cd..59877353b5 100644 --- a/command/agent/agent.go +++ b/agent/agent.go @@ -21,10 +21,10 @@ import ( "sync" "time" + "github.com/hashicorp/consul/agent/consul" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/ipaddr" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/logger" @@ -169,7 +169,7 @@ type Agent struct { wgServers sync.WaitGroup } -func NewAgent(c *Config) (*Agent, error) { +func New(c *Config) (*Agent, error) { if c.Datacenter == "" { return nil, fmt.Errorf("Must configure a Datacenter") } @@ -1029,8 +1029,8 @@ func (a *Agent) setupNodeID(config *Config) error { // setupKeyrings is used to initialize and load keyrings during agent startup func (a *Agent) setupKeyrings(config *consul.Config) error { - fileLAN := filepath.Join(a.config.DataDir, serfLANKeyring) - fileWAN := filepath.Join(a.config.DataDir, serfWANKeyring) + fileLAN := filepath.Join(a.config.DataDir, SerfLANKeyring) + fileWAN := filepath.Join(a.config.DataDir, SerfWANKeyring) if a.config.EncryptKey == "" { goto LOAD diff --git a/command/agent/agent_endpoint.go b/agent/agent_endpoint.go similarity index 99% rename from command/agent/agent_endpoint.go rename to agent/agent_endpoint.go index a5871af5f9..7460c870be 100644 --- a/command/agent/agent_endpoint.go +++ b/agent/agent_endpoint.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/ipaddr" "github.com/hashicorp/consul/logger" "github.com/hashicorp/consul/types" diff --git a/command/agent/agent_endpoint_test.go b/agent/agent_endpoint_test.go similarity index 99% rename from command/agent/agent_endpoint_test.go rename to agent/agent_endpoint_test.go index 4894553825..5d423eb12f 100644 --- a/command/agent/agent_endpoint_test.go +++ b/agent/agent_endpoint_test.go @@ -13,8 +13,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/logger" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/consul/types" diff --git a/command/agent/agent_test.go b/agent/agent_test.go similarity index 99% rename from command/agent/agent_test.go rename to agent/agent_test.go index f4de82afb1..0c5079e932 100644 --- a/command/agent/agent_test.go +++ b/agent/agent_test.go @@ -14,9 +14,9 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/consul/types" "github.com/hashicorp/consul/version" diff --git a/command/agent/bindata_assetfs.go b/agent/bindata_assetfs.go similarity index 100% rename from command/agent/bindata_assetfs.go rename to agent/bindata_assetfs.go diff --git a/command/agent/catalog_endpoint.go b/agent/catalog_endpoint.go similarity index 98% rename from command/agent/catalog_endpoint.go rename to agent/catalog_endpoint.go index b13554d0ae..325c23e578 100644 --- a/command/agent/catalog_endpoint.go +++ b/agent/catalog_endpoint.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) func (s *HTTPServer) CatalogRegister(resp http.ResponseWriter, req *http.Request) (interface{}, error) { diff --git a/command/agent/catalog_endpoint_test.go b/agent/catalog_endpoint_test.go similarity index 99% rename from command/agent/catalog_endpoint_test.go rename to agent/catalog_endpoint_test.go index 3f9bfcdb3c..fe85d1fb91 100644 --- a/command/agent/catalog_endpoint_test.go +++ b/agent/catalog_endpoint_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/serf/coordinate" ) diff --git a/command/agent/check.go b/agent/check.go similarity index 99% rename from command/agent/check.go rename to agent/check.go index 50a67172ae..afb6908cb3 100644 --- a/command/agent/check.go +++ b/agent/check.go @@ -15,8 +15,8 @@ import ( "github.com/armon/circbuf" docker "github.com/fsouza/go-dockerclient" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-cleanhttp" diff --git a/command/agent/check_test.go b/agent/check_test.go similarity index 99% rename from command/agent/check_test.go rename to agent/check_test.go index 3aea6c254d..7d98db303a 100644 --- a/command/agent/check_test.go +++ b/agent/check_test.go @@ -17,8 +17,8 @@ import ( "time" docker "github.com/fsouza/go-dockerclient" + "github.com/hashicorp/consul/agent/mock" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/agent/mock" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/consul/types" ) diff --git a/command/agent/config.go b/agent/config.go similarity index 99% rename from command/agent/config.go rename to agent/config.go index ce8aa2b2ce..79ee16fe68 100644 --- a/command/agent/config.go +++ b/agent/config.go @@ -14,7 +14,7 @@ import ( "strings" "time" - "github.com/hashicorp/consul/consul" + "github.com/hashicorp/consul/agent/consul" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/tlsutil" "github.com/hashicorp/consul/types" @@ -1006,9 +1006,9 @@ func (c *Config) GetTokenForAgent() string { return "" } -// verifyUniqueListeners checks to see if an address was used more than once in +// VerifyUniqueListeners checks to see if an address was used more than once in // the config -func (c *Config) verifyUniqueListeners() error { +func (c *Config) VerifyUniqueListeners() error { listeners := []struct { host string port int diff --git a/command/agent/config_aws.go b/agent/config_aws.go similarity index 100% rename from command/agent/config_aws.go rename to agent/config_aws.go diff --git a/command/agent/config_azure.go b/agent/config_azure.go similarity index 100% rename from command/agent/config_azure.go rename to agent/config_azure.go diff --git a/command/agent/config_azure_test.go b/agent/config_azure_test.go similarity index 100% rename from command/agent/config_azure_test.go rename to agent/config_azure_test.go diff --git a/command/agent/config_ec2_test.go b/agent/config_ec2_test.go similarity index 100% rename from command/agent/config_ec2_test.go rename to agent/config_ec2_test.go diff --git a/command/agent/config_gce.go b/agent/config_gce.go similarity index 100% rename from command/agent/config_gce.go rename to agent/config_gce.go diff --git a/command/agent/config_gce_test.go b/agent/config_gce_test.go similarity index 100% rename from command/agent/config_gce_test.go rename to agent/config_gce_test.go diff --git a/command/agent/config_test.go b/agent/config_test.go similarity index 99% rename from command/agent/config_test.go rename to agent/config_test.go index 1a802ffe60..c5070c1fe8 100644 --- a/command/agent/config_test.go +++ b/agent/config_test.go @@ -1207,7 +1207,7 @@ func TestDecodeConfig_VerifyUniqueListeners(t *testing.T) { t.Fatalf("got error %v want nil", err) } - err = c.verifyUniqueListeners() + err = c.VerifyUniqueListeners() if got, want := err, tt.err; !reflect.DeepEqual(got, want) { t.Fatalf("got error %v want %v", got, want) } diff --git a/consul/acl.go b/agent/consul/acl.go similarity index 99% rename from consul/acl.go rename to agent/consul/acl.go index 6c732733f0..c17fbdf7c1 100644 --- a/consul/acl.go +++ b/agent/consul/acl.go @@ -10,7 +10,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/golang-lru" ) diff --git a/consul/acl_endpoint.go b/agent/consul/acl_endpoint.go similarity index 98% rename from consul/acl_endpoint.go rename to agent/consul/acl_endpoint.go index 49042b8427..57a6ed7c34 100644 --- a/consul/acl_endpoint.go +++ b/agent/consul/acl_endpoint.go @@ -6,8 +6,8 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/go-uuid" ) diff --git a/consul/acl_endpoint_test.go b/agent/consul/acl_endpoint_test.go similarity index 99% rename from consul/acl_endpoint_test.go rename to agent/consul/acl_endpoint_test.go index 4e524dc325..8870753191 100644 --- a/consul/acl_endpoint_test.go +++ b/agent/consul/acl_endpoint_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" diff --git a/consul/acl_replication.go b/agent/consul/acl_replication.go similarity index 99% rename from consul/acl_replication.go rename to agent/consul/acl_replication.go index 4b9b9d017d..e60df9407f 100644 --- a/consul/acl_replication.go +++ b/agent/consul/acl_replication.go @@ -6,7 +6,7 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/lib" ) diff --git a/consul/acl_replication_test.go b/agent/consul/acl_replication_test.go similarity index 99% rename from consul/acl_replication_test.go rename to agent/consul/acl_replication_test.go index a8801c15ce..3ef739a47f 100644 --- a/consul/acl_replication_test.go +++ b/agent/consul/acl_replication_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" ) diff --git a/consul/acl_test.go b/agent/consul/acl_test.go similarity index 99% rename from consul/acl_test.go rename to agent/consul/acl_test.go index 480c792cfd..830df24e8d 100644 --- a/consul/acl_test.go +++ b/agent/consul/acl_test.go @@ -8,7 +8,7 @@ import ( "time" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" ) diff --git a/consul/agent/server.go b/agent/consul/agent/server.go similarity index 100% rename from consul/agent/server.go rename to agent/consul/agent/server.go diff --git a/consul/agent/server_internal_test.go b/agent/consul/agent/server_internal_test.go similarity index 100% rename from consul/agent/server_internal_test.go rename to agent/consul/agent/server_internal_test.go diff --git a/consul/agent/server_test.go b/agent/consul/agent/server_test.go similarity index 98% rename from consul/agent/server_test.go rename to agent/consul/agent/server_test.go index 30365599c0..f12ca97371 100644 --- a/consul/agent/server_test.go +++ b/agent/consul/agent/server_test.go @@ -4,7 +4,7 @@ import ( "net" "testing" - "github.com/hashicorp/consul/consul/agent" + "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/serf/serf" ) diff --git a/consul/autopilot.go b/agent/consul/autopilot.go similarity index 99% rename from consul/autopilot.go rename to agent/consul/autopilot.go index 34d28f457d..5b81bb0ce4 100644 --- a/consul/autopilot.go +++ b/agent/consul/autopilot.go @@ -8,8 +8,8 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/consul/agent" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-version" "github.com/hashicorp/raft" "github.com/hashicorp/serf/serf" diff --git a/consul/autopilot_test.go b/agent/consul/autopilot_test.go similarity index 100% rename from consul/autopilot_test.go rename to agent/consul/autopilot_test.go diff --git a/consul/catalog_endpoint.go b/agent/consul/catalog_endpoint.go similarity index 98% rename from consul/catalog_endpoint.go rename to agent/consul/catalog_endpoint.go index 5d35786293..1e75b16b69 100644 --- a/consul/catalog_endpoint.go +++ b/agent/consul/catalog_endpoint.go @@ -5,8 +5,8 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/ipaddr" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-memdb" diff --git a/consul/catalog_endpoint_test.go b/agent/consul/catalog_endpoint_test.go similarity index 99% rename from consul/catalog_endpoint_test.go rename to agent/consul/catalog_endpoint_test.go index 86f1622fa3..048db553a4 100644 --- a/consul/catalog_endpoint_test.go +++ b/agent/consul/catalog_endpoint_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" diff --git a/consul/client.go b/agent/consul/client.go similarity index 98% rename from consul/client.go rename to agent/consul/client.go index 9a258f198d..00af759420 100644 --- a/consul/client.go +++ b/agent/consul/client.go @@ -11,9 +11,9 @@ import ( "sync" "time" - "github.com/hashicorp/consul/consul/agent" - "github.com/hashicorp/consul/consul/servers" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/consul/servers" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/serf/coordinate" "github.com/hashicorp/serf/serf" diff --git a/consul/client_test.go b/agent/consul/client_test.go similarity index 99% rename from consul/client_test.go rename to agent/consul/client_test.go index af0dc81b4e..3560d839b5 100644 --- a/consul/client_test.go +++ b/agent/consul/client_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/consul/testutil/retry" diff --git a/consul/config.go b/agent/consul/config.go similarity index 99% rename from consul/config.go rename to agent/consul/config.go index 73495fc61d..820e8cbea3 100644 --- a/consul/config.go +++ b/agent/consul/config.go @@ -7,7 +7,7 @@ import ( "os" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/tlsutil" "github.com/hashicorp/consul/types" "github.com/hashicorp/memberlist" diff --git a/consul/config_test.go b/agent/consul/config_test.go similarity index 100% rename from consul/config_test.go rename to agent/consul/config_test.go diff --git a/consul/coordinate_endpoint.go b/agent/consul/coordinate_endpoint.go similarity index 98% rename from consul/coordinate_endpoint.go rename to agent/consul/coordinate_endpoint.go index e6979cfdcb..696a6be37c 100644 --- a/consul/coordinate_endpoint.go +++ b/agent/consul/coordinate_endpoint.go @@ -6,8 +6,8 @@ import ( "sync" "time" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/serf/coordinate" ) diff --git a/consul/coordinate_endpoint_test.go b/agent/consul/coordinate_endpoint_test.go similarity index 99% rename from consul/coordinate_endpoint_test.go rename to agent/consul/coordinate_endpoint_test.go index 3158ceba91..2debf2872e 100644 --- a/consul/coordinate_endpoint_test.go +++ b/agent/consul/coordinate_endpoint_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/consul/filter.go b/agent/consul/filter.go similarity index 97% rename from consul/filter.go rename to agent/consul/filter.go index 85682a3bb2..1e6806b28b 100644 --- a/consul/filter.go +++ b/agent/consul/filter.go @@ -2,7 +2,7 @@ package consul import ( "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) type dirEntFilter struct { diff --git a/consul/filter_test.go b/agent/consul/filter_test.go similarity index 98% rename from consul/filter_test.go rename to agent/consul/filter_test.go index c4602c8c7a..9568102cc8 100644 --- a/consul/filter_test.go +++ b/agent/consul/filter_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) func TestFilter_DirEnt(t *testing.T) { diff --git a/consul/flood.go b/agent/consul/flood.go similarity index 96% rename from consul/flood.go rename to agent/consul/flood.go index fb3b09b8f5..12705c8b9d 100644 --- a/consul/flood.go +++ b/agent/consul/flood.go @@ -3,7 +3,7 @@ package consul import ( "time" - "github.com/hashicorp/consul/consul/servers" + "github.com/hashicorp/consul/agent/consul/servers" "github.com/hashicorp/serf/serf" ) diff --git a/consul/fsm.go b/agent/consul/fsm.go similarity index 99% rename from consul/fsm.go rename to agent/consul/fsm.go index 87d3d71dc7..8258ba22b7 100644 --- a/consul/fsm.go +++ b/agent/consul/fsm.go @@ -8,9 +8,9 @@ import ( "time" "github.com/armon/go-metrics" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/go-msgpack/codec" "github.com/hashicorp/raft" ) diff --git a/consul/fsm_test.go b/agent/consul/fsm_test.go similarity index 99% rename from consul/fsm_test.go rename to agent/consul/fsm_test.go index 9bfaffdffe..a34af91160 100644 --- a/consul/fsm_test.go +++ b/agent/consul/fsm_test.go @@ -9,9 +9,9 @@ import ( "time" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-uuid" diff --git a/consul/health_endpoint.go b/agent/consul/health_endpoint.go similarity index 97% rename from consul/health_endpoint.go rename to agent/consul/health_endpoint.go index 56a1be9c81..8d9d9ac46a 100644 --- a/consul/health_endpoint.go +++ b/agent/consul/health_endpoint.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" ) diff --git a/consul/health_endpoint_test.go b/agent/consul/health_endpoint_test.go similarity index 99% rename from consul/health_endpoint_test.go rename to agent/consul/health_endpoint_test.go index 2d0dea8807..6ec90a3f90 100644 --- a/consul/health_endpoint_test.go +++ b/agent/consul/health_endpoint_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/consul/helper_test.go b/agent/consul/helper_test.go similarity index 100% rename from consul/helper_test.go rename to agent/consul/helper_test.go diff --git a/consul/internal_endpoint.go b/agent/consul/internal_endpoint.go similarity index 97% rename from consul/internal_endpoint.go rename to agent/consul/internal_endpoint.go index fe45ccd466..546d66975c 100644 --- a/consul/internal_endpoint.go +++ b/agent/consul/internal_endpoint.go @@ -3,8 +3,8 @@ package consul import ( "fmt" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/serf/serf" ) diff --git a/consul/internal_endpoint_test.go b/agent/consul/internal_endpoint_test.go similarity index 99% rename from consul/internal_endpoint_test.go rename to agent/consul/internal_endpoint_test.go index 8b1fc51ace..af2e5c8852 100644 --- a/consul/internal_endpoint_test.go +++ b/agent/consul/internal_endpoint_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/consul/issue_test.go b/agent/consul/issue_test.go similarity index 96% rename from consul/issue_test.go rename to agent/consul/issue_test.go index bbaeb2299e..3f0435fcc0 100644 --- a/consul/issue_test.go +++ b/agent/consul/issue_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" ) // Testing for GH-300 and GH-279 diff --git a/consul/kvs_endpoint.go b/agent/consul/kvs_endpoint.go similarity index 98% rename from consul/kvs_endpoint.go rename to agent/consul/kvs_endpoint.go index e47832e5c6..ef1c067fb7 100644 --- a/consul/kvs_endpoint.go +++ b/agent/consul/kvs_endpoint.go @@ -6,9 +6,9 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/acl" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/go-memdb" ) diff --git a/consul/kvs_endpoint_test.go b/agent/consul/kvs_endpoint_test.go similarity index 99% rename from consul/kvs_endpoint_test.go rename to agent/consul/kvs_endpoint_test.go index 4acbdfa560..2f1bb4026a 100644 --- a/consul/kvs_endpoint_test.go +++ b/agent/consul/kvs_endpoint_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" ) diff --git a/consul/leader.go b/agent/consul/leader.go similarity index 99% rename from consul/leader.go rename to agent/consul/leader.go index 7a1bfd358f..a1c1ce50c9 100644 --- a/consul/leader.go +++ b/agent/consul/leader.go @@ -9,9 +9,9 @@ import ( "time" "github.com/armon/go-metrics" + "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/agent" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/types" "github.com/hashicorp/raft" "github.com/hashicorp/serf/serf" diff --git a/consul/leader_test.go b/agent/consul/leader_test.go similarity index 99% rename from consul/leader_test.go rename to agent/consul/leader_test.go index d804bc070e..9a2d218d64 100644 --- a/consul/leader_test.go +++ b/agent/consul/leader_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/consul/merge.go b/agent/consul/merge.go similarity index 97% rename from consul/merge.go rename to agent/consul/merge.go index 335d0280a4..b361772dcd 100644 --- a/consul/merge.go +++ b/agent/consul/merge.go @@ -3,7 +3,7 @@ package consul import ( "fmt" - "github.com/hashicorp/consul/consul/agent" + "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/consul/types" "github.com/hashicorp/serf/serf" ) diff --git a/consul/merge_test.go b/agent/consul/merge_test.go similarity index 100% rename from consul/merge_test.go rename to agent/consul/merge_test.go diff --git a/consul/operator_autopilot_endpoint.go b/agent/consul/operator_autopilot_endpoint.go similarity index 98% rename from consul/operator_autopilot_endpoint.go rename to agent/consul/operator_autopilot_endpoint.go index 219d039996..141d321790 100644 --- a/consul/operator_autopilot_endpoint.go +++ b/agent/consul/operator_autopilot_endpoint.go @@ -3,7 +3,7 @@ package consul import ( "fmt" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) // AutopilotGetConfiguration is used to retrieve the current Autopilot configuration. diff --git a/consul/operator_autopilot_endpoint_test.go b/agent/consul/operator_autopilot_endpoint_test.go similarity index 99% rename from consul/operator_autopilot_endpoint_test.go rename to agent/consul/operator_autopilot_endpoint_test.go index 80e1eec9be..d9725bb9cd 100644 --- a/consul/operator_autopilot_endpoint_test.go +++ b/agent/consul/operator_autopilot_endpoint_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/consul/operator_endpoint.go b/agent/consul/operator_endpoint.go similarity index 100% rename from consul/operator_endpoint.go rename to agent/consul/operator_endpoint.go diff --git a/consul/operator_raft_endpoint.go b/agent/consul/operator_raft_endpoint.go similarity index 98% rename from consul/operator_raft_endpoint.go rename to agent/consul/operator_raft_endpoint.go index 9aa1ca87ef..d4feeeb1d1 100644 --- a/consul/operator_raft_endpoint.go +++ b/agent/consul/operator_raft_endpoint.go @@ -4,8 +4,8 @@ import ( "fmt" "net" - "github.com/hashicorp/consul/consul/agent" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/raft" "github.com/hashicorp/serf/serf" ) diff --git a/consul/operator_raft_endpoint_test.go b/agent/consul/operator_raft_endpoint_test.go similarity index 99% rename from consul/operator_raft_endpoint_test.go rename to agent/consul/operator_raft_endpoint_test.go index 169608dd9e..b7852e832c 100644 --- a/consul/operator_raft_endpoint_test.go +++ b/agent/consul/operator_raft_endpoint_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" "github.com/hashicorp/raft" diff --git a/consul/pool.go b/agent/consul/pool.go similarity index 99% rename from consul/pool.go rename to agent/consul/pool.go index 9dde11e6e9..67f1b39b4e 100644 --- a/consul/pool.go +++ b/agent/consul/pool.go @@ -10,7 +10,7 @@ import ( "sync/atomic" "time" - "github.com/hashicorp/consul/consul/agent" + "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/consul/tlsutil" "github.com/hashicorp/net-rpc-msgpackrpc" "github.com/hashicorp/yamux" diff --git a/consul/prepared_query/template.go b/agent/consul/prepared_query/template.go similarity index 98% rename from consul/prepared_query/template.go rename to agent/consul/prepared_query/template.go index 9473829d6b..f758de2ce6 100644 --- a/consul/prepared_query/template.go +++ b/agent/consul/prepared_query/template.go @@ -6,7 +6,7 @@ import ( "regexp" "strings" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/hil" "github.com/hashicorp/hil/ast" "github.com/mitchellh/copystructure" diff --git a/consul/prepared_query/template_test.go b/agent/consul/prepared_query/template_test.go similarity index 99% rename from consul/prepared_query/template_test.go rename to agent/consul/prepared_query/template_test.go index 9a9ad90a87..32d54117bb 100644 --- a/consul/prepared_query/template_test.go +++ b/agent/consul/prepared_query/template_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/mitchellh/copystructure" ) diff --git a/consul/prepared_query/walk.go b/agent/consul/prepared_query/walk.go similarity index 100% rename from consul/prepared_query/walk.go rename to agent/consul/prepared_query/walk.go diff --git a/consul/prepared_query/walk_test.go b/agent/consul/prepared_query/walk_test.go similarity index 95% rename from consul/prepared_query/walk_test.go rename to agent/consul/prepared_query/walk_test.go index 33de1a3f80..9d9d9533cb 100644 --- a/consul/prepared_query/walk_test.go +++ b/agent/consul/prepared_query/walk_test.go @@ -5,8 +5,9 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/consul/structs" "sort" + + "github.com/hashicorp/consul/agent/consul/structs" ) func TestWalk_ServiceQuery(t *testing.T) { diff --git a/consul/prepared_query_endpoint.go b/agent/consul/prepared_query_endpoint.go similarity index 99% rename from consul/prepared_query_endpoint.go rename to agent/consul/prepared_query_endpoint.go index 8b329ebe69..3b78702a7e 100644 --- a/consul/prepared_query_endpoint.go +++ b/agent/consul/prepared_query_endpoint.go @@ -8,8 +8,8 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/go-uuid" ) diff --git a/consul/prepared_query_endpoint_test.go b/agent/consul/prepared_query_endpoint_test.go similarity index 99% rename from consul/prepared_query_endpoint_test.go rename to agent/consul/prepared_query_endpoint_test.go index 7ca4f51a77..7be180ebd9 100644 --- a/consul/prepared_query_endpoint_test.go +++ b/agent/consul/prepared_query_endpoint_test.go @@ -12,8 +12,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/consul/raft_rpc.go b/agent/consul/raft_rpc.go similarity index 100% rename from consul/raft_rpc.go rename to agent/consul/raft_rpc.go diff --git a/consul/rpc.go b/agent/consul/rpc.go similarity index 98% rename from consul/rpc.go rename to agent/consul/rpc.go index eef78d9f47..5ea9c8e496 100644 --- a/consul/rpc.go +++ b/agent/consul/rpc.go @@ -9,9 +9,9 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/consul/agent" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/go-memdb" "github.com/hashicorp/memberlist" diff --git a/consul/rpc_test.go b/agent/consul/rpc_test.go similarity index 97% rename from consul/rpc_test.go rename to agent/consul/rpc_test.go index 450571197d..6e08d67e19 100644 --- a/consul/rpc_test.go +++ b/agent/consul/rpc_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/go-memdb" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/consul/rtt.go b/agent/consul/rtt.go similarity index 99% rename from consul/rtt.go rename to agent/consul/rtt.go index ea0c0ad6a8..392f13d4fa 100644 --- a/consul/rtt.go +++ b/agent/consul/rtt.go @@ -4,7 +4,7 @@ import ( "fmt" "sort" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/serf/coordinate" ) diff --git a/consul/rtt_test.go b/agent/consul/rtt_test.go similarity index 99% rename from consul/rtt_test.go rename to agent/consul/rtt_test.go index e959c5cf3d..6452e17f67 100644 --- a/consul/rtt_test.go +++ b/agent/consul/rtt_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/consul/serf.go b/agent/consul/serf.go similarity index 99% rename from consul/serf.go rename to agent/consul/serf.go index d65eabbffc..b9e50e0763 100644 --- a/consul/serf.go +++ b/agent/consul/serf.go @@ -4,7 +4,7 @@ import ( "strings" "time" - "github.com/hashicorp/consul/consul/agent" + "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/raft" "github.com/hashicorp/serf/serf" ) diff --git a/consul/serf_test.go b/agent/consul/serf_test.go similarity index 100% rename from consul/serf_test.go rename to agent/consul/serf_test.go diff --git a/consul/server.go b/agent/consul/server.go similarity index 99% rename from consul/server.go rename to agent/consul/server.go index 95098d9933..4a4661a645 100644 --- a/consul/server.go +++ b/agent/consul/server.go @@ -17,10 +17,10 @@ import ( "time" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/consul/agent" - "github.com/hashicorp/consul/consul/servers" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/consul/servers" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/tlsutil" "github.com/hashicorp/consul/types" diff --git a/consul/server_test.go b/agent/consul/server_test.go similarity index 95% rename from consul/server_test.go rename to agent/consul/server_test.go index 471b0b7245..cdb6e3bb45 100644 --- a/consul/server_test.go +++ b/agent/consul/server_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/agent" + "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/consul/testutil/retry" @@ -22,9 +22,9 @@ func getPort() int { } func configureTLS(config *Config) { - config.CAFile = "../test/ca/root.cer" - config.CertFile = "../test/key/ourdomain.cer" - config.KeyFile = "../test/key/ourdomain.key" + config.CAFile = "../../test/ca/root.cer" + config.CertFile = "../../test/key/ourdomain.cer" + config.KeyFile = "../../test/key/ourdomain.key" } func testServerConfig(t *testing.T, NodeName string) (string, *Config) { @@ -607,9 +607,9 @@ func TestServer_TLSToNoTLS(t *testing.T) { // Add a second server with TLS configured dir2, s2 := testServerWithConfig(t, func(c *Config) { c.Bootstrap = false - c.CAFile = "../test/client_certs/rootca.crt" - c.CertFile = "../test/client_certs/server.crt" - c.KeyFile = "../test/client_certs/server.key" + c.CAFile = "../../test/client_certs/rootca.crt" + c.CertFile = "../../test/client_certs/server.crt" + c.KeyFile = "../../test/client_certs/server.key" }) defer os.RemoveAll(dir2) defer s2.Shutdown() @@ -634,9 +634,9 @@ func TestServer_TLSForceOutgoingToNoTLS(t *testing.T) { // Add a second server with TLS and VerifyOutgoing set dir2, s2 := testServerWithConfig(t, func(c *Config) { c.Bootstrap = false - c.CAFile = "../test/client_certs/rootca.crt" - c.CertFile = "../test/client_certs/server.crt" - c.KeyFile = "../test/client_certs/server.key" + c.CAFile = "../../test/client_certs/rootca.crt" + c.CertFile = "../../test/client_certs/server.crt" + c.KeyFile = "../../test/client_certs/server.key" c.VerifyOutgoing = true }) defer os.RemoveAll(dir2) @@ -651,9 +651,9 @@ func TestServer_TLSForceOutgoingToNoTLS(t *testing.T) { func TestServer_TLSToFullVerify(t *testing.T) { // Set up a server with TLS and VerifyIncoming set dir1, s1 := testServerWithConfig(t, func(c *Config) { - c.CAFile = "../test/client_certs/rootca.crt" - c.CertFile = "../test/client_certs/server.crt" - c.KeyFile = "../test/client_certs/server.key" + c.CAFile = "../../test/client_certs/rootca.crt" + c.CertFile = "../../test/client_certs/server.crt" + c.KeyFile = "../../test/client_certs/server.key" c.VerifyIncoming = true c.VerifyOutgoing = true }) @@ -665,9 +665,9 @@ func TestServer_TLSToFullVerify(t *testing.T) { // Add a second server with TLS configured dir2, s2 := testServerWithConfig(t, func(c *Config) { c.Bootstrap = false - c.CAFile = "../test/client_certs/rootca.crt" - c.CertFile = "../test/client_certs/server.crt" - c.KeyFile = "../test/client_certs/server.key" + c.CAFile = "../../test/client_certs/rootca.crt" + c.CertFile = "../../test/client_certs/server.crt" + c.KeyFile = "../../test/client_certs/server.key" }) defer os.RemoveAll(dir2) defer s2.Shutdown() diff --git a/consul/servers/manager.go b/agent/consul/servers/manager.go similarity index 99% rename from consul/servers/manager.go rename to agent/consul/servers/manager.go index 7071e058d7..263b796ec4 100644 --- a/consul/servers/manager.go +++ b/agent/consul/servers/manager.go @@ -12,7 +12,7 @@ import ( "sync/atomic" "time" - "github.com/hashicorp/consul/consul/agent" + "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/consul/lib" ) diff --git a/consul/servers/manager_internal_test.go b/agent/consul/servers/manager_internal_test.go similarity index 99% rename from consul/servers/manager_internal_test.go rename to agent/consul/servers/manager_internal_test.go index 6ca5759cec..5a5d76a584 100644 --- a/consul/servers/manager_internal_test.go +++ b/agent/consul/servers/manager_internal_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/agent" + "github.com/hashicorp/consul/agent/consul/agent" ) var ( diff --git a/consul/servers/manager_test.go b/agent/consul/servers/manager_test.go similarity index 98% rename from consul/servers/manager_test.go rename to agent/consul/servers/manager_test.go index b87ea84faa..2ed0154386 100644 --- a/consul/servers/manager_test.go +++ b/agent/consul/servers/manager_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/consul/agent" - "github.com/hashicorp/consul/consul/servers" + "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/consul/servers" ) type fauxConnPool struct { diff --git a/consul/servers/router.go b/agent/consul/servers/router.go similarity index 99% rename from consul/servers/router.go rename to agent/consul/servers/router.go index 54360cbf97..7bf4f2def9 100644 --- a/consul/servers/router.go +++ b/agent/consul/servers/router.go @@ -6,8 +6,8 @@ import ( "sort" "sync" - "github.com/hashicorp/consul/consul/agent" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" "github.com/hashicorp/serf/coordinate" diff --git a/consul/servers/router_test.go b/agent/consul/servers/router_test.go similarity index 99% rename from consul/servers/router_test.go rename to agent/consul/servers/router_test.go index 6171d30d5d..c04785c7d1 100644 --- a/consul/servers/router_test.go +++ b/agent/consul/servers/router_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" "github.com/hashicorp/serf/coordinate" diff --git a/consul/servers/serf_adapter.go b/agent/consul/servers/serf_adapter.go similarity index 97% rename from consul/servers/serf_adapter.go rename to agent/consul/servers/serf_adapter.go index 09b7c95d3f..052696b4ac 100644 --- a/consul/servers/serf_adapter.go +++ b/agent/consul/servers/serf_adapter.go @@ -3,7 +3,7 @@ package servers import ( "log" - "github.com/hashicorp/consul/consul/agent" + "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/consul/types" "github.com/hashicorp/serf/serf" ) diff --git a/consul/servers/serf_flooder.go b/agent/consul/servers/serf_flooder.go similarity index 98% rename from consul/servers/serf_flooder.go rename to agent/consul/servers/serf_flooder.go index 4a2f83ce45..bf49aee67b 100644 --- a/consul/servers/serf_flooder.go +++ b/agent/consul/servers/serf_flooder.go @@ -6,7 +6,7 @@ import ( "net" "strings" - "github.com/hashicorp/consul/consul/agent" + "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/serf/serf" ) diff --git a/consul/session_endpoint.go b/agent/consul/session_endpoint.go similarity index 98% rename from consul/session_endpoint.go rename to agent/consul/session_endpoint.go index 6d5bc8ddd8..d8379ff947 100644 --- a/consul/session_endpoint.go +++ b/agent/consul/session_endpoint.go @@ -5,8 +5,8 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/consul/state" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/go-uuid" ) diff --git a/consul/session_endpoint_test.go b/agent/consul/session_endpoint_test.go similarity index 99% rename from consul/session_endpoint_test.go rename to agent/consul/session_endpoint_test.go index f5ca6bb7bd..96e8406e9c 100644 --- a/consul/session_endpoint_test.go +++ b/agent/consul/session_endpoint_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/consul/session_ttl.go b/agent/consul/session_ttl.go similarity index 98% rename from consul/session_ttl.go rename to agent/consul/session_ttl.go index c4398fe63f..dfebb3c0c9 100644 --- a/consul/session_ttl.go +++ b/agent/consul/session_ttl.go @@ -5,7 +5,7 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) const ( diff --git a/consul/session_ttl_test.go b/agent/consul/session_ttl_test.go similarity index 99% rename from consul/session_ttl_test.go rename to agent/consul/session_ttl_test.go index f7f57098d2..5cf75129dd 100644 --- a/consul/session_ttl_test.go +++ b/agent/consul/session_ttl_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/consul/snapshot_endpoint.go b/agent/consul/snapshot_endpoint.go similarity index 99% rename from consul/snapshot_endpoint.go rename to agent/consul/snapshot_endpoint.go index b29e873f50..8005172637 100644 --- a/consul/snapshot_endpoint.go +++ b/agent/consul/snapshot_endpoint.go @@ -16,7 +16,7 @@ import ( "net" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/snapshot" "github.com/hashicorp/go-msgpack/codec" ) diff --git a/consul/snapshot_endpoint_test.go b/agent/consul/snapshot_endpoint_test.go similarity index 99% rename from consul/snapshot_endpoint_test.go rename to agent/consul/snapshot_endpoint_test.go index cb3254f414..d745d158d0 100644 --- a/consul/snapshot_endpoint_test.go +++ b/agent/consul/snapshot_endpoint_test.go @@ -6,8 +6,8 @@ import ( "strings" "testing" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/consul/state/acl.go b/agent/consul/state/acl.go similarity index 98% rename from consul/state/acl.go rename to agent/consul/state/acl.go index d6d9d9ccf9..d1e0589ef2 100644 --- a/consul/state/acl.go +++ b/agent/consul/state/acl.go @@ -3,7 +3,7 @@ package state import ( "fmt" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/acl_test.go b/agent/consul/state/acl_test.go similarity index 99% rename from consul/state/acl_test.go rename to agent/consul/state/acl_test.go index 2d7bb21396..013a543655 100644 --- a/consul/state/acl_test.go +++ b/agent/consul/state/acl_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/autopilot.go b/agent/consul/state/autopilot.go similarity index 98% rename from consul/state/autopilot.go rename to agent/consul/state/autopilot.go index fc31eb46d9..9469a20fe4 100644 --- a/consul/state/autopilot.go +++ b/agent/consul/state/autopilot.go @@ -3,7 +3,7 @@ package state import ( "fmt" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/autopilot_test.go b/agent/consul/state/autopilot_test.go similarity index 97% rename from consul/state/autopilot_test.go rename to agent/consul/state/autopilot_test.go index 4e1e1c5b72..91187a473e 100644 --- a/consul/state/autopilot_test.go +++ b/agent/consul/state/autopilot_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) func TestStateStore_Autopilot(t *testing.T) { diff --git a/consul/state/catalog.go b/agent/consul/state/catalog.go similarity index 99% rename from consul/state/catalog.go rename to agent/consul/state/catalog.go index 59bfaf28cf..173fa85c01 100644 --- a/consul/state/catalog.go +++ b/agent/consul/state/catalog.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/catalog_test.go b/agent/consul/state/catalog_test.go similarity index 99% rename from consul/state/catalog_test.go rename to agent/consul/state/catalog_test.go index 0a7316dc54..b5ca5df460 100644 --- a/consul/state/catalog_test.go +++ b/agent/consul/state/catalog_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-memdb" diff --git a/consul/state/coordinate.go b/agent/consul/state/coordinate.go similarity index 98% rename from consul/state/coordinate.go rename to agent/consul/state/coordinate.go index eaa606d27d..38696f3154 100644 --- a/consul/state/coordinate.go +++ b/agent/consul/state/coordinate.go @@ -3,7 +3,7 @@ package state import ( "fmt" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/serf/coordinate" ) diff --git a/consul/state/coordinate_test.go b/agent/consul/state/coordinate_test.go similarity index 99% rename from consul/state/coordinate_test.go rename to agent/consul/state/coordinate_test.go index defbc092f5..b2fe8633e6 100644 --- a/consul/state/coordinate_test.go +++ b/agent/consul/state/coordinate_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/serf/coordinate" ) diff --git a/consul/state/delay.go b/agent/consul/state/delay.go similarity index 100% rename from consul/state/delay.go rename to agent/consul/state/delay.go diff --git a/consul/state/delay_test.go b/agent/consul/state/delay_test.go similarity index 100% rename from consul/state/delay_test.go rename to agent/consul/state/delay_test.go diff --git a/consul/state/graveyard.go b/agent/consul/state/graveyard.go similarity index 100% rename from consul/state/graveyard.go rename to agent/consul/state/graveyard.go diff --git a/consul/state/graveyard_test.go b/agent/consul/state/graveyard_test.go similarity index 100% rename from consul/state/graveyard_test.go rename to agent/consul/state/graveyard_test.go diff --git a/consul/state/kvs.go b/agent/consul/state/kvs.go similarity index 99% rename from consul/state/kvs.go rename to agent/consul/state/kvs.go index 2ae20d445f..87845b3daf 100644 --- a/consul/state/kvs.go +++ b/agent/consul/state/kvs.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/kvs_test.go b/agent/consul/state/kvs_test.go similarity index 99% rename from consul/state/kvs_test.go rename to agent/consul/state/kvs_test.go index e3134563cc..a12778d398 100644 --- a/consul/state/kvs_test.go +++ b/agent/consul/state/kvs_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/notify.go b/agent/consul/state/notify.go similarity index 100% rename from consul/state/notify.go rename to agent/consul/state/notify.go diff --git a/consul/state/notify_test.go b/agent/consul/state/notify_test.go similarity index 100% rename from consul/state/notify_test.go rename to agent/consul/state/notify_test.go diff --git a/consul/state/prepared_query.go b/agent/consul/state/prepared_query.go similarity index 99% rename from consul/state/prepared_query.go rename to agent/consul/state/prepared_query.go index 9ca653e95a..c610be5c72 100644 --- a/consul/state/prepared_query.go +++ b/agent/consul/state/prepared_query.go @@ -4,8 +4,8 @@ import ( "fmt" "regexp" - "github.com/hashicorp/consul/consul/prepared_query" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/prepared_query" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/prepared_query_index.go b/agent/consul/state/prepared_query_index.go similarity index 96% rename from consul/state/prepared_query_index.go rename to agent/consul/state/prepared_query_index.go index d0fef04ea8..b3c30807aa 100644 --- a/consul/state/prepared_query_index.go +++ b/agent/consul/state/prepared_query_index.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/hashicorp/consul/consul/prepared_query" + "github.com/hashicorp/consul/agent/consul/prepared_query" ) // PreparedQueryIndex is a custom memdb indexer used to manage index prepared diff --git a/consul/state/prepared_query_index_test.go b/agent/consul/state/prepared_query_index_test.go similarity index 98% rename from consul/state/prepared_query_index_test.go rename to agent/consul/state/prepared_query_index_test.go index 6f7edc6ac0..46dc8cf538 100644 --- a/consul/state/prepared_query_index_test.go +++ b/agent/consul/state/prepared_query_index_test.go @@ -3,7 +3,7 @@ package state import ( "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) // Indexer is a global indexer to use for tests since there is no state. diff --git a/consul/state/prepared_query_test.go b/agent/consul/state/prepared_query_test.go similarity index 99% rename from consul/state/prepared_query_test.go rename to agent/consul/state/prepared_query_test.go index b42bde8e79..49d7061774 100644 --- a/consul/state/prepared_query_test.go +++ b/agent/consul/state/prepared_query_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/schema.go b/agent/consul/state/schema.go similarity index 100% rename from consul/state/schema.go rename to agent/consul/state/schema.go diff --git a/consul/state/schema_test.go b/agent/consul/state/schema_test.go similarity index 100% rename from consul/state/schema_test.go rename to agent/consul/state/schema_test.go diff --git a/consul/state/session.go b/agent/consul/state/session.go similarity index 99% rename from consul/state/session.go rename to agent/consul/state/session.go index e41d43c7b8..b4135f2407 100644 --- a/consul/state/session.go +++ b/agent/consul/state/session.go @@ -4,8 +4,8 @@ import ( "fmt" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/session_test.go b/agent/consul/state/session_test.go similarity index 99% rename from consul/state/session_test.go rename to agent/consul/state/session_test.go index 5a54b1bdc7..220563fd72 100644 --- a/consul/state/session_test.go +++ b/agent/consul/state/session_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/state_store.go b/agent/consul/state/state_store.go similarity index 100% rename from consul/state/state_store.go rename to agent/consul/state/state_store.go diff --git a/consul/state/state_store_test.go b/agent/consul/state/state_store_test.go similarity index 98% rename from consul/state/state_store_test.go rename to agent/consul/state/state_store_test.go index 73f33db3af..c8bcab4b3e 100644 --- a/consul/state/state_store_test.go +++ b/agent/consul/state/state_store_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/tombstone_gc.go b/agent/consul/state/tombstone_gc.go similarity index 100% rename from consul/state/tombstone_gc.go rename to agent/consul/state/tombstone_gc.go diff --git a/consul/state/tombstone_gc_test.go b/agent/consul/state/tombstone_gc_test.go similarity index 100% rename from consul/state/tombstone_gc_test.go rename to agent/consul/state/tombstone_gc_test.go diff --git a/consul/state/txn.go b/agent/consul/state/txn.go similarity index 98% rename from consul/state/txn.go rename to agent/consul/state/txn.go index b821d13d3f..191d594708 100644 --- a/consul/state/txn.go +++ b/agent/consul/state/txn.go @@ -3,8 +3,8 @@ package state import ( "fmt" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/go-memdb" ) diff --git a/consul/state/txn_test.go b/agent/consul/state/txn_test.go similarity index 99% rename from consul/state/txn_test.go rename to agent/consul/state/txn_test.go index 24254cea6f..8c9936961e 100644 --- a/consul/state/txn_test.go +++ b/agent/consul/state/txn_test.go @@ -5,8 +5,8 @@ import ( "strings" "testing" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" ) func TestStateStore_Txn_KVS(t *testing.T) { diff --git a/consul/stats_fetcher.go b/agent/consul/stats_fetcher.go similarity index 96% rename from consul/stats_fetcher.go rename to agent/consul/stats_fetcher.go index 209411a5d3..acbf69eb4d 100644 --- a/consul/stats_fetcher.go +++ b/agent/consul/stats_fetcher.go @@ -5,8 +5,8 @@ import ( "log" "sync" - "github.com/hashicorp/consul/consul/agent" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/consul/structs" ) // StatsFetcher has two functions for autopilot. First, lets us fetch all the diff --git a/consul/stats_fetcher_test.go b/agent/consul/stats_fetcher_test.go similarity index 97% rename from consul/stats_fetcher_test.go rename to agent/consul/stats_fetcher_test.go index d8615545fb..978bb1162e 100644 --- a/consul/stats_fetcher_test.go +++ b/agent/consul/stats_fetcher_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/agent" + "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/types" ) diff --git a/consul/status_endpoint.go b/agent/consul/status_endpoint.go similarity index 96% rename from consul/status_endpoint.go rename to agent/consul/status_endpoint.go index 8c6e3fcfbe..ccdf19c40a 100644 --- a/consul/status_endpoint.go +++ b/agent/consul/status_endpoint.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) // Status endpoint is used to check on server status diff --git a/consul/status_endpoint_test.go b/agent/consul/status_endpoint_test.go similarity index 100% rename from consul/status_endpoint_test.go rename to agent/consul/status_endpoint_test.go diff --git a/consul/structs/operator.go b/agent/consul/structs/operator.go similarity index 100% rename from consul/structs/operator.go rename to agent/consul/structs/operator.go diff --git a/consul/structs/operator_test.go b/agent/consul/structs/operator_test.go similarity index 100% rename from consul/structs/operator_test.go rename to agent/consul/structs/operator_test.go diff --git a/consul/structs/prepared_query.go b/agent/consul/structs/prepared_query.go similarity index 100% rename from consul/structs/prepared_query.go rename to agent/consul/structs/prepared_query.go diff --git a/consul/structs/prepared_query_test.go b/agent/consul/structs/prepared_query_test.go similarity index 100% rename from consul/structs/prepared_query_test.go rename to agent/consul/structs/prepared_query_test.go diff --git a/consul/structs/snapshot.go b/agent/consul/structs/snapshot.go similarity index 100% rename from consul/structs/snapshot.go rename to agent/consul/structs/snapshot.go diff --git a/consul/structs/structs.go b/agent/consul/structs/structs.go similarity index 100% rename from consul/structs/structs.go rename to agent/consul/structs/structs.go diff --git a/consul/structs/structs_test.go b/agent/consul/structs/structs_test.go similarity index 100% rename from consul/structs/structs_test.go rename to agent/consul/structs/structs_test.go diff --git a/consul/structs/txn.go b/agent/consul/structs/txn.go similarity index 100% rename from consul/structs/txn.go rename to agent/consul/structs/txn.go diff --git a/consul/txn_endpoint.go b/agent/consul/txn_endpoint.go similarity index 98% rename from consul/txn_endpoint.go rename to agent/consul/txn_endpoint.go index 45b511be39..7aefdc8cc3 100644 --- a/consul/txn_endpoint.go +++ b/agent/consul/txn_endpoint.go @@ -6,7 +6,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) // Txn endpoint is used to perform multi-object atomic transactions. diff --git a/consul/txn_endpoint_test.go b/agent/consul/txn_endpoint_test.go similarity index 99% rename from consul/txn_endpoint_test.go rename to agent/consul/txn_endpoint_test.go index d839d26d82..c2b71fe117 100644 --- a/consul/txn_endpoint_test.go +++ b/agent/consul/txn_endpoint_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" ) diff --git a/consul/util.go b/agent/consul/util.go similarity index 99% rename from consul/util.go rename to agent/consul/util.go index dd04a340b6..92c0b66836 100644 --- a/consul/util.go +++ b/agent/consul/util.go @@ -7,7 +7,7 @@ import ( "runtime" "strconv" - "github.com/hashicorp/consul/consul/agent" + "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/go-version" "github.com/hashicorp/serf/serf" ) diff --git a/consul/util_test.go b/agent/consul/util_test.go similarity index 100% rename from consul/util_test.go rename to agent/consul/util_test.go diff --git a/command/agent/coordinate_endpoint.go b/agent/coordinate_endpoint.go similarity index 97% rename from command/agent/coordinate_endpoint.go rename to agent/coordinate_endpoint.go index 0ad94fe8c9..bf9f38713d 100644 --- a/command/agent/coordinate_endpoint.go +++ b/agent/coordinate_endpoint.go @@ -5,7 +5,7 @@ import ( "net/http" "sort" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) // coordinateDisabled handles all the endpoints when coordinates are not enabled, diff --git a/command/agent/coordinate_endpoint_test.go b/agent/coordinate_endpoint_test.go similarity index 97% rename from command/agent/coordinate_endpoint_test.go rename to agent/coordinate_endpoint_test.go index 8782a2a426..449d55ae2e 100644 --- a/command/agent/coordinate_endpoint_test.go +++ b/agent/coordinate_endpoint_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/serf/coordinate" ) diff --git a/command/agent/dns.go b/agent/dns.go similarity index 99% rename from command/agent/dns.go rename to agent/dns.go index 90b156eb2f..53bdb41581 100644 --- a/command/agent/dns.go +++ b/agent/dns.go @@ -9,8 +9,8 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/consul" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/lib" "github.com/miekg/dns" ) diff --git a/command/agent/dns_test.go b/agent/dns_test.go similarity index 99% rename from command/agent/dns_test.go rename to agent/dns_test.go index e5ee307671..139b45ffd8 100644 --- a/command/agent/dns_test.go +++ b/agent/dns_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testutil/retry" "github.com/miekg/dns" diff --git a/command/agent/event_endpoint.go b/agent/event_endpoint.go similarity index 98% rename from command/agent/event_endpoint.go rename to agent/event_endpoint.go index e6d38244e7..3eedb32fc2 100644 --- a/command/agent/event_endpoint.go +++ b/agent/event_endpoint.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) const ( diff --git a/command/agent/event_endpoint_test.go b/agent/event_endpoint_test.go similarity index 99% rename from command/agent/event_endpoint_test.go rename to agent/event_endpoint_test.go index 08171be859..d842b64fd5 100644 --- a/command/agent/event_endpoint_test.go +++ b/agent/event_endpoint_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testutil/retry" ) diff --git a/command/agent/health_endpoint.go b/agent/health_endpoint.go similarity index 99% rename from command/agent/health_endpoint.go rename to agent/health_endpoint.go index 2e9765a9f5..d877ca9298 100644 --- a/command/agent/health_endpoint.go +++ b/agent/health_endpoint.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" ) func (s *HTTPServer) HealthChecksInState(resp http.ResponseWriter, req *http.Request) (interface{}, error) { diff --git a/command/agent/health_endpoint_test.go b/agent/health_endpoint_test.go similarity index 99% rename from command/agent/health_endpoint_test.go rename to agent/health_endpoint_test.go index 3dde89ad6c..9dcbbff4fd 100644 --- a/command/agent/health_endpoint_test.go +++ b/agent/health_endpoint_test.go @@ -9,8 +9,8 @@ import ( "reflect" "testing" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/serf/coordinate" ) diff --git a/command/agent/http.go b/agent/http.go similarity index 99% rename from command/agent/http.go rename to agent/http.go index 5763f24898..d622958c9c 100644 --- a/command/agent/http.go +++ b/agent/http.go @@ -11,7 +11,7 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/mitchellh/mapstructure" ) diff --git a/command/agent/http_test.go b/agent/http_test.go similarity index 99% rename from command/agent/http_test.go rename to agent/http_test.go index 223af26936..3c02d75a58 100644 --- a/command/agent/http_test.go +++ b/agent/http_test.go @@ -18,7 +18,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/go-cleanhttp" ) diff --git a/command/agent/keyring.go b/agent/keyring.go similarity index 96% rename from command/agent/keyring.go rename to agent/keyring.go index f06ca22aab..e1171d45ee 100644 --- a/command/agent/keyring.go +++ b/agent/keyring.go @@ -8,15 +8,15 @@ import ( "os" "path/filepath" - "github.com/hashicorp/consul/consul" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/memberlist" "github.com/hashicorp/serf/serf" ) const ( - serfLANKeyring = "serf/local.keyring" - serfWANKeyring = "serf/remote.keyring" + SerfLANKeyring = "serf/local.keyring" + SerfWANKeyring = "serf/remote.keyring" ) // initKeyring will create a keyring file at a given path. diff --git a/command/agent/keyring_test.go b/agent/keyring_test.go similarity index 100% rename from command/agent/keyring_test.go rename to agent/keyring_test.go diff --git a/command/agent/kvs_endpoint.go b/agent/kvs_endpoint.go similarity index 99% rename from command/agent/kvs_endpoint.go rename to agent/kvs_endpoint.go index 687194d106..c271d64d48 100644 --- a/command/agent/kvs_endpoint.go +++ b/agent/kvs_endpoint.go @@ -8,8 +8,8 @@ import ( "strconv" "strings" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" ) const ( diff --git a/command/agent/kvs_endpoint_test.go b/agent/kvs_endpoint_test.go similarity index 99% rename from command/agent/kvs_endpoint_test.go rename to agent/kvs_endpoint_test.go index da6b7444b4..f03a637cfb 100644 --- a/command/agent/kvs_endpoint_test.go +++ b/agent/kvs_endpoint_test.go @@ -8,7 +8,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) func TestKVSEndpoint_PUT_GET_DELETE(t *testing.T) { diff --git a/command/agent/local.go b/agent/local.go similarity index 99% rename from command/agent/local.go rename to agent/local.go index 5af99d4235..810bbec3f4 100644 --- a/command/agent/local.go +++ b/agent/local.go @@ -9,9 +9,9 @@ import ( "sync/atomic" "time" + "github.com/hashicorp/consul/agent/consul" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" ) diff --git a/command/agent/local_test.go b/agent/local_test.go similarity index 99% rename from command/agent/local_test.go rename to agent/local_test.go index 237ede2ac5..338b1962ea 100644 --- a/command/agent/local_test.go +++ b/agent/local_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/consul/types" ) diff --git a/command/agent/mock/notify.go b/agent/mock/notify.go similarity index 100% rename from command/agent/mock/notify.go rename to agent/mock/notify.go diff --git a/command/agent/operator_endpoint.go b/agent/operator_endpoint.go similarity index 99% rename from command/agent/operator_endpoint.go rename to agent/operator_endpoint.go index 8e59938249..4a23b61742 100644 --- a/command/agent/operator_endpoint.go +++ b/agent/operator_endpoint.go @@ -7,8 +7,8 @@ import ( "strings" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/raft" ) diff --git a/command/agent/operator_endpoint_test.go b/agent/operator_endpoint_test.go similarity index 99% rename from command/agent/operator_endpoint_test.go rename to agent/operator_endpoint_test.go index dd89c5c567..d0e5debb73 100644 --- a/command/agent/operator_endpoint_test.go +++ b/agent/operator_endpoint_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/testutil/retry" ) diff --git a/command/agent/prepared_query_endpoint.go b/agent/prepared_query_endpoint.go similarity index 98% rename from command/agent/prepared_query_endpoint.go rename to agent/prepared_query_endpoint.go index 5dd7bbd6e5..bbfc9e6ea7 100644 --- a/command/agent/prepared_query_endpoint.go +++ b/agent/prepared_query_endpoint.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - "github.com/hashicorp/consul/consul" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul" + "github.com/hashicorp/consul/agent/consul/structs" ) const ( diff --git a/command/agent/prepared_query_endpoint_test.go b/agent/prepared_query_endpoint_test.go similarity index 99% rename from command/agent/prepared_query_endpoint_test.go rename to agent/prepared_query_endpoint_test.go index 2b188d0205..0d1ef6d5c0 100644 --- a/command/agent/prepared_query_endpoint_test.go +++ b/agent/prepared_query_endpoint_test.go @@ -9,7 +9,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) // MockPreparedQuery is a fake endpoint that we inject into the Consul server diff --git a/command/agent/remote_exec.go b/agent/remote_exec.go similarity index 99% rename from command/agent/remote_exec.go rename to agent/remote_exec.go index 9e3b1e339d..333f874550 100644 --- a/command/agent/remote_exec.go +++ b/agent/remote_exec.go @@ -12,8 +12,8 @@ import ( "syscall" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" ) const ( diff --git a/command/agent/remote_exec_test.go b/agent/remote_exec_test.go similarity index 99% rename from command/agent/remote_exec_test.go rename to agent/remote_exec_test.go index da0695f4bc..890520e919 100644 --- a/command/agent/remote_exec_test.go +++ b/agent/remote_exec_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/go-uuid" ) diff --git a/command/agent/retry_join.go b/agent/retry_join.go similarity index 100% rename from command/agent/retry_join.go rename to agent/retry_join.go diff --git a/command/agent/session_endpoint.go b/agent/session_endpoint.go similarity index 98% rename from command/agent/session_endpoint.go rename to agent/session_endpoint.go index b0d792b267..8a5e2a3118 100644 --- a/command/agent/session_endpoint.go +++ b/agent/session_endpoint.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/hashicorp/consul/consul" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/types" ) diff --git a/command/agent/session_endpoint_test.go b/agent/session_endpoint_test.go similarity index 99% rename from command/agent/session_endpoint_test.go rename to agent/session_endpoint_test.go index 6d34db4d7e..13c381ba2e 100644 --- a/command/agent/session_endpoint_test.go +++ b/agent/session_endpoint_test.go @@ -8,9 +8,9 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent/consul" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/types" ) diff --git a/command/agent/snapshot_endpoint.go b/agent/snapshot_endpoint.go similarity index 95% rename from command/agent/snapshot_endpoint.go rename to agent/snapshot_endpoint.go index 06bf150d78..e6abfa1d25 100644 --- a/command/agent/snapshot_endpoint.go +++ b/agent/snapshot_endpoint.go @@ -4,7 +4,7 @@ import ( "bytes" "net/http" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) // Snapshot handles requests to take and restore snapshots. This uses a special diff --git a/command/agent/snapshot_endpoint_test.go b/agent/snapshot_endpoint_test.go similarity index 100% rename from command/agent/snapshot_endpoint_test.go rename to agent/snapshot_endpoint_test.go diff --git a/command/agent/status_endpoint.go b/agent/status_endpoint.go similarity index 100% rename from command/agent/status_endpoint.go rename to agent/status_endpoint.go diff --git a/command/agent/status_endpoint_test.go b/agent/status_endpoint_test.go similarity index 100% rename from command/agent/status_endpoint_test.go rename to agent/status_endpoint_test.go diff --git a/command/agent/structs.go b/agent/structs.go similarity index 98% rename from command/agent/structs.go rename to agent/structs.go index d269fbbdc5..9ecf8df55f 100644 --- a/command/agent/structs.go +++ b/agent/structs.go @@ -3,8 +3,8 @@ package agent import ( "time" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/types" ) diff --git a/command/agent/structs_test.go b/agent/structs_test.go similarity index 100% rename from command/agent/structs_test.go rename to agent/structs_test.go diff --git a/command/agent/testagent.go b/agent/testagent.go similarity index 97% rename from command/agent/testagent.go rename to agent/testagent.go index 0090462edf..4d77eaf696 100644 --- a/command/agent/testagent.go +++ b/agent/testagent.go @@ -15,9 +15,9 @@ import ( "strings" "time" + "github.com/hashicorp/consul/agent/consul" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/logger" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/consul/types" @@ -131,11 +131,11 @@ func (a *TestAgent) Start() *TestAgent { panic(fmt.Sprintf("Error creating keyring %s: %s", path, err)) } } - writeKey(a.Key, serfLANKeyring) - writeKey(a.Key, serfWANKeyring) + writeKey(a.Key, SerfLANKeyring) + writeKey(a.Key, SerfWANKeyring) } - agent, err := NewAgent(a.Config) + agent, err := New(a.Config) if err != nil { panic(fmt.Sprintf("Error creating agent: %s", err)) } diff --git a/command/agent/translate_addr.go b/agent/translate_addr.go similarity index 97% rename from command/agent/translate_addr.go rename to agent/translate_addr.go index 7ca65a4932..425e1a3a83 100644 --- a/command/agent/translate_addr.go +++ b/agent/translate_addr.go @@ -3,7 +3,7 @@ package agent import ( "fmt" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) // translateAddress is used to provide the final, translated address for a node, diff --git a/command/agent/txn_endpoint.go b/agent/txn_endpoint.go similarity index 99% rename from command/agent/txn_endpoint.go rename to agent/txn_endpoint.go index f8ec051895..961994a0ff 100644 --- a/command/agent/txn_endpoint.go +++ b/agent/txn_endpoint.go @@ -6,8 +6,8 @@ import ( "net/http" "strings" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" ) const ( diff --git a/command/agent/txn_endpoint_test.go b/agent/txn_endpoint_test.go similarity index 99% rename from command/agent/txn_endpoint_test.go rename to agent/txn_endpoint_test.go index e9de14e595..91c7bed45c 100644 --- a/command/agent/txn_endpoint_test.go +++ b/agent/txn_endpoint_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" ) func TestTxnEndpoint_Bad_JSON(t *testing.T) { diff --git a/command/agent/ui_endpoint.go b/agent/ui_endpoint.go similarity index 98% rename from command/agent/ui_endpoint.go rename to agent/ui_endpoint.go index 67ba1edeca..7cb254818a 100644 --- a/command/agent/ui_endpoint.go +++ b/agent/ui_endpoint.go @@ -6,8 +6,8 @@ import ( "sort" "strings" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" ) // ServiceSummary is used to summarize a service diff --git a/command/agent/ui_endpoint_test.go b/agent/ui_endpoint_test.go similarity index 99% rename from command/agent/ui_endpoint_test.go rename to agent/ui_endpoint_test.go index 3cbcf6e0d1..f1c1bae545 100644 --- a/command/agent/ui_endpoint_test.go +++ b/agent/ui_endpoint_test.go @@ -12,8 +12,8 @@ import ( "reflect" "testing" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/consul/structs" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/go-cleanhttp" ) diff --git a/command/agent/user_event.go b/agent/user_event.go similarity index 99% rename from command/agent/user_event.go rename to agent/user_event.go index 63265e71ab..5d27135b73 100644 --- a/command/agent/user_event.go +++ b/agent/user_event.go @@ -4,7 +4,7 @@ import ( "fmt" "regexp" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/go-uuid" ) diff --git a/command/agent/user_event_test.go b/agent/user_event_test.go similarity index 98% rename from command/agent/user_event_test.go rename to agent/user_event_test.go index e5ff987b79..fdafb0bd3e 100644 --- a/command/agent/user_event_test.go +++ b/agent/user_event_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testutil/retry" ) diff --git a/command/agent/util.go b/agent/util.go similarity index 100% rename from command/agent/util.go rename to agent/util.go diff --git a/command/agent/util_test.go b/agent/util_test.go similarity index 100% rename from command/agent/util_test.go rename to agent/util_test.go diff --git a/command/agent/watch_handler.go b/agent/watch_handler.go similarity index 100% rename from command/agent/watch_handler.go rename to agent/watch_handler.go diff --git a/command/agent/watch_handler_test.go b/agent/watch_handler_test.go similarity index 100% rename from command/agent/watch_handler_test.go rename to agent/watch_handler_test.go diff --git a/command/agent/command.go b/command/agent.go similarity index 92% rename from command/agent/command.go rename to command/agent.go index 596ea453d4..3faf96a7a1 100644 --- a/command/agent/command.go +++ b/command/agent.go @@ -1,4 +1,4 @@ -package agent +package command import ( "encoding/json" @@ -16,8 +16,8 @@ import ( "github.com/armon/go-metrics" "github.com/armon/go-metrics/circonus" "github.com/armon/go-metrics/datadog" - "github.com/hashicorp/consul/command/base" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/ipaddr" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/logger" @@ -31,12 +31,12 @@ import ( // validDatacenter is used to validate a datacenter var validDatacenter = regexp.MustCompile("^[a-zA-Z0-9_-]+$") -// Command is a Command implementation that runs a Consul agent. +// AgentCommand is a Command implementation that runs a Consul agent. // The command will not end unless a shutdown message is sent on the // ShutdownCh. If two messages are sent on the ShutdownCh it will forcibly // exit. -type Command struct { - base.Command +type AgentCommand struct { + BaseCommand Revision string Version string VersionPrerelease string @@ -50,8 +50,8 @@ type Command struct { // readConfig is responsible for setup of our configuration using // the command line and any file configs -func (cmd *Command) readConfig() *Config { - var cmdCfg Config +func (cmd *AgentCommand) readConfig() *agent.Config { + var cmdCfg agent.Config var cfgFiles []string var retryInterval string var retryIntervalWan string @@ -59,7 +59,7 @@ func (cmd *Command) readConfig() *Config { var dev bool var nodeMeta []string - f := cmd.Command.NewFlagSet(cmd) + f := cmd.BaseCommand.NewFlagSet(cmd) f.Var((*AppendSliceValue)(&cfgFiles), "config-file", "Path to a JSON file to read configuration from. This can be specified multiple times.") @@ -169,7 +169,7 @@ func (cmd *Command) readConfig() *Config { f.StringVar(&atlasEndpoint, "atlas-endpoint", "", "(deprecated) The address of the endpoint for Atlas integration.") - if err := cmd.Command.Parse(cmd.args); err != nil { + if err := cmd.BaseCommand.Parse(cmd.args); err != nil { return nil } @@ -212,29 +212,29 @@ func (cmd *Command) readConfig() *Config { if len(nodeMeta) > 0 { cmdCfg.Meta = make(map[string]string) for _, entry := range nodeMeta { - key, value := ParseMetaPair(entry) + key, value := agent.ParseMetaPair(entry) cmdCfg.Meta[key] = value } } - cfg := DefaultConfig() + cfg := agent.DefaultConfig() if dev { - cfg = DevConfig() + cfg = agent.DevConfig() } if len(cfgFiles) > 0 { - fileConfig, err := ReadConfigPaths(cfgFiles) + fileConfig, err := agent.ReadConfigPaths(cfgFiles) if err != nil { cmd.UI.Error(err.Error()) return nil } - cfg = MergeConfig(cfg, fileConfig) + cfg = agent.MergeConfig(cfg, fileConfig) } cmdCfg.DNSRecursors = append(cmdCfg.DNSRecursors, dnsRecursors...) - cfg = MergeConfig(cfg, &cmdCfg) + cfg = agent.MergeConfig(cfg, &cmdCfg) if cfg.NodeName == "" { hostname, err := os.Hostname() @@ -253,10 +253,10 @@ func (cmd *Command) readConfig() *Config { // Make sure LeaveOnTerm and SkipLeaveOnInt are set to the right // defaults based on the agent's mode (client or server). if cfg.LeaveOnTerm == nil { - cfg.LeaveOnTerm = Bool(!cfg.Server) + cfg.LeaveOnTerm = agent.Bool(!cfg.Server) } if cfg.SkipLeaveOnInt == nil { - cfg.SkipLeaveOnInt = Bool(cfg.Server) + cfg.SkipLeaveOnInt = agent.Bool(cfg.Server) } // Ensure we have a data directory if we are not in dev mode. @@ -278,7 +278,7 @@ func (cmd *Command) readConfig() *Config { } // Ensure all endpoints are unique - if err := cfg.verifyUniqueListeners(); err != nil { + if err := cfg.VerifyUniqueListeners(); err != nil { cmd.UI.Error(fmt.Sprintf("All listening endpoints must be unique: %s", err)) return nil } @@ -312,12 +312,12 @@ func (cmd *Command) readConfig() *Config { cmd.UI.Error(fmt.Sprintf("Invalid encryption key: %s", err)) return nil } - keyfileLAN := filepath.Join(cfg.DataDir, serfLANKeyring) + keyfileLAN := filepath.Join(cfg.DataDir, agent.SerfLANKeyring) if _, err := os.Stat(keyfileLAN); err == nil { cmd.UI.Error("WARNING: LAN keyring exists but -encrypt given, using keyring") } if cfg.Server { - keyfileWAN := filepath.Join(cfg.DataDir, serfWANKeyring) + keyfileWAN := filepath.Join(cfg.DataDir, agent.SerfWANKeyring) if _, err := os.Stat(keyfileWAN); err == nil { cmd.UI.Error("WARNING: WAN keyring exists but -encrypt given, using keyring") } @@ -449,7 +449,7 @@ func (cmd *Command) readConfig() *Config { } // checkpointResults is used to handler periodic results from our update checker -func (cmd *Command) checkpointResults(results *checkpoint.CheckResponse, err error) { +func (cmd *AgentCommand) checkpointResults(results *checkpoint.CheckResponse, err error) { if err != nil { cmd.UI.Error(fmt.Sprintf("Failed to check for updates: %v", err)) return @@ -467,7 +467,7 @@ func (cmd *Command) checkpointResults(results *checkpoint.CheckResponse, err err } } -func (cmd *Command) startupUpdateCheck(config *Config) { +func (cmd *AgentCommand) startupUpdateCheck(config *agent.Config) { version := config.Version if config.VersionPrerelease != "" { version += fmt.Sprintf("-%s", config.VersionPrerelease) @@ -491,7 +491,7 @@ func (cmd *Command) startupUpdateCheck(config *Config) { } // startupJoin is invoked to handle any joins specified to take place at start time -func (cmd *Command) startupJoin(agent *Agent, cfg *Config) error { +func (cmd *AgentCommand) startupJoin(agent *agent.Agent, cfg *agent.Config) error { if len(cfg.StartJoin) == 0 { return nil } @@ -507,7 +507,7 @@ func (cmd *Command) startupJoin(agent *Agent, cfg *Config) error { } // startupJoinWan is invoked to handle any joins -wan specified to take place at start time -func (cmd *Command) startupJoinWan(agent *Agent, cfg *Config) error { +func (cmd *AgentCommand) startupJoinWan(agent *agent.Agent, cfg *agent.Config) error { if len(cfg.StartJoinWan) == 0 { return nil } @@ -522,21 +522,21 @@ func (cmd *Command) startupJoinWan(agent *Agent, cfg *Config) error { return nil } -func statsiteSink(config *Config, hostname string) (metrics.MetricSink, error) { +func statsiteSink(config *agent.Config, hostname string) (metrics.MetricSink, error) { if config.Telemetry.StatsiteAddr == "" { return nil, nil } return metrics.NewStatsiteSink(config.Telemetry.StatsiteAddr) } -func statsdSink(config *Config, hostname string) (metrics.MetricSink, error) { +func statsdSink(config *agent.Config, hostname string) (metrics.MetricSink, error) { if config.Telemetry.StatsdAddr == "" { return nil, nil } return metrics.NewStatsdSink(config.Telemetry.StatsdAddr) } -func dogstatdSink(config *Config, hostname string) (metrics.MetricSink, error) { +func dogstatdSink(config *agent.Config, hostname string) (metrics.MetricSink, error) { if config.Telemetry.DogStatsdAddr == "" { return nil, nil } @@ -548,7 +548,7 @@ func dogstatdSink(config *Config, hostname string) (metrics.MetricSink, error) { return sink, nil } -func circonusSink(config *Config, hostname string) (metrics.MetricSink, error) { +func circonusSink(config *agent.Config, hostname string) (metrics.MetricSink, error) { if config.Telemetry.CirconusAPIToken == "" && config.Telemetry.CirconusCheckSubmissionURL == "" { return nil, nil } @@ -588,7 +588,7 @@ func circonusSink(config *Config, hostname string) (metrics.MetricSink, error) { return sink, nil } -func startupTelemetry(config *Config) error { +func startupTelemetry(config *agent.Config) error { // Setup telemetry // Aggregate on 10 second intervals for 1 minute. Expose the // metrics over stderr when there is a SIGUSR1 received. @@ -598,7 +598,7 @@ func startupTelemetry(config *Config) error { metricsConf.EnableHostname = !config.Telemetry.DisableHostname var sinks metrics.FanoutSink - addSink := func(name string, fn func(*Config, string) (metrics.MetricSink, error)) error { + addSink := func(name string, fn func(*agent.Config, string) (metrics.MetricSink, error)) error { s, err := fn(config, metricsConf.HostName) if err != nil { return err @@ -632,7 +632,7 @@ func startupTelemetry(config *Config) error { return nil } -func (cmd *Command) Run(args []string) int { +func (cmd *AgentCommand) Run(args []string) int { code := cmd.run(args) if cmd.logger != nil { cmd.logger.Println("[INFO] Exit code: ", code) @@ -640,7 +640,7 @@ func (cmd *Command) Run(args []string) int { return code } -func (cmd *Command) run(args []string) int { +func (cmd *AgentCommand) run(args []string) int { cmd.UI = &cli.PrefixedUi{ OutputPrefix: "==> ", InfoPrefix: " ", @@ -676,7 +676,7 @@ func (cmd *Command) run(args []string) int { // Create the agent cmd.UI.Output("Starting Consul agent...") - agent, err := NewAgent(config) + agent, err := agent.New(config) if err != nil { cmd.UI.Error(fmt.Sprintf("Error creating agent: %s", err)) return 1 @@ -745,7 +745,7 @@ func (cmd *Command) run(args []string) int { cmd.logger.Println("[ERR] Retry join failed: ", err) return 1 case <-agent.ShutdownCh(): - // Agent is already down! + // agent is already down! return 0 } @@ -804,7 +804,7 @@ func (cmd *Command) run(args []string) int { } // handleReload is invoked when we should reload our configs, e.g. SIGHUP -func (cmd *Command) handleReload(agent *Agent, cfg *Config) (*Config, error) { +func (cmd *AgentCommand) handleReload(agent *agent.Agent, cfg *agent.Config) (*agent.Config, error) { cmd.logger.Println("[INFO] Reloading configuration...") var errs error newCfg := cmd.readConfig() @@ -833,18 +833,18 @@ func (cmd *Command) handleReload(agent *Agent, cfg *Config) (*Config, error) { return cfg, errs } -func (cmd *Command) Synopsis() string { +func (cmd *AgentCommand) Synopsis() string { return "Runs a Consul agent" } -func (cmd *Command) Help() string { +func (cmd *AgentCommand) Help() string { helpText := ` Usage: consul agent [options] Starts the Consul agent and runs until an interrupt is received. The agent represents a single node in a cluster. - ` + cmd.Command.Help() + ` + cmd.BaseCommand.Help() return strings.TrimSpace(helpText) } diff --git a/command/agent/command_test.go b/command/agent_test.go similarity index 86% rename from command/agent/command_test.go rename to command/agent_test.go index 29ea690245..3948a7b225 100644 --- a/command/agent/command_test.go +++ b/command/agent_test.go @@ -1,4 +1,4 @@ -package agent +package command import ( "fmt" @@ -10,23 +10,23 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/consul/version" "github.com/mitchellh/cli" ) -func baseCommand(ui *cli.MockUi) base.Command { - return base.Command{ - Flags: base.FlagSetNone, +func baseCommand(ui *cli.MockUi) BaseCommand { + return BaseCommand{ + Flags: FlagSetNone, UI: ui, } } func TestCommand_implements(t *testing.T) { t.Parallel() - var _ cli.Command = new(Command) + var _ cli.Command = new(AgentCommand) } func TestValidDatacenter(t *testing.T) { @@ -103,10 +103,10 @@ func TestConfigFail(t *testing.T) { func TestRetryJoin(t *testing.T) { t.Skip("fs: skipping tests that use cmd.Run until signal handling is fixed") t.Parallel() - a := NewTestAgent(t.Name(), nil) + a := agent.NewTestAgent(t.Name(), nil) defer a.Shutdown() - cfg2 := TestConfig() + cfg2 := agent.TestConfig() tmpDir := testutil.TempDir(t, "consul") defer os.RemoveAll(tmpDir) @@ -118,10 +118,10 @@ func TestRetryJoin(t *testing.T) { <-doneCh }() - cmd := &Command{ - Version: version.Version, - ShutdownCh: shutdownCh, - Command: baseCommand(cli.NewMockUi()), + cmd := &AgentCommand{ + Version: version.Version, + ShutdownCh: shutdownCh, + BaseCommand: baseCommand(cli.NewMockUi()), } serfAddr := fmt.Sprintf( @@ -172,7 +172,7 @@ func TestReadCliConfig(t *testing.T) { // Test config parse { - cmd := &Command{ + cmd := &AgentCommand{ args: []string{ "-data-dir", tmpDir, "-node", `"a"`, @@ -181,8 +181,8 @@ func TestReadCliConfig(t *testing.T) { "-serf-lan-bind", "4.3.2.2", "-node-meta", "somekey:somevalue", }, - ShutdownCh: shutdownCh, - Command: baseCommand(cli.NewMockUi()), + ShutdownCh: shutdownCh, + BaseCommand: baseCommand(cli.NewMockUi()), } config := cmd.readConfig() @@ -202,14 +202,14 @@ func TestReadCliConfig(t *testing.T) { // Test multiple node meta flags { - cmd := &Command{ + cmd := &AgentCommand{ args: []string{ "-data-dir", tmpDir, "-node-meta", "somekey:somevalue", "-node-meta", "otherkey:othervalue", }, - ShutdownCh: shutdownCh, - Command: baseCommand(cli.NewMockUi()), + ShutdownCh: shutdownCh, + BaseCommand: baseCommand(cli.NewMockUi()), } expected := map[string]string{ "somekey": "somevalue", @@ -224,14 +224,14 @@ func TestReadCliConfig(t *testing.T) { // Test LeaveOnTerm and SkipLeaveOnInt defaults for server mode { ui := cli.NewMockUi() - cmd := &Command{ + cmd := &AgentCommand{ args: []string{ "-node", `"server1"`, "-server", "-data-dir", tmpDir, }, - ShutdownCh: shutdownCh, - Command: baseCommand(ui), + ShutdownCh: shutdownCh, + BaseCommand: baseCommand(ui), } config := cmd.readConfig() @@ -252,13 +252,13 @@ func TestReadCliConfig(t *testing.T) { // Test LeaveOnTerm and SkipLeaveOnInt defaults for client mode { ui := cli.NewMockUi() - cmd := &Command{ + cmd := &AgentCommand{ args: []string{ "-data-dir", tmpDir, "-node", `"client"`, }, - ShutdownCh: shutdownCh, - Command: baseCommand(ui), + ShutdownCh: shutdownCh, + BaseCommand: baseCommand(ui), } config := cmd.readConfig() @@ -278,10 +278,10 @@ func TestReadCliConfig(t *testing.T) { // Test empty node name { - cmd := &Command{ - args: []string{"-node", `""`}, - ShutdownCh: shutdownCh, - Command: baseCommand(cli.NewMockUi()), + cmd := &AgentCommand{ + args: []string{"-node", `""`}, + ShutdownCh: shutdownCh, + BaseCommand: baseCommand(cli.NewMockUi()), } config := cmd.readConfig() @@ -294,16 +294,16 @@ func TestReadCliConfig(t *testing.T) { func TestRetryJoinFail(t *testing.T) { t.Skip("fs: skipping tests that use cmd.Run until signal handling is fixed") t.Parallel() - cfg := TestConfig() + cfg := agent.TestConfig() tmpDir := testutil.TempDir(t, "consul") defer os.RemoveAll(tmpDir) shutdownCh := make(chan struct{}) defer close(shutdownCh) - cmd := &Command{ - ShutdownCh: shutdownCh, - Command: baseCommand(cli.NewMockUi()), + cmd := &AgentCommand{ + ShutdownCh: shutdownCh, + BaseCommand: baseCommand(cli.NewMockUi()), } serfAddr := fmt.Sprintf("%s:%d", cfg.BindAddr, cfg.Ports.SerfLan) @@ -324,16 +324,16 @@ func TestRetryJoinFail(t *testing.T) { func TestRetryJoinWanFail(t *testing.T) { t.Skip("fs: skipping tests that use cmd.Run until signal handling is fixed") t.Parallel() - cfg := TestConfig() + cfg := agent.TestConfig() tmpDir := testutil.TempDir(t, "consul") defer os.RemoveAll(tmpDir) shutdownCh := make(chan struct{}) defer close(shutdownCh) - cmd := &Command{ - ShutdownCh: shutdownCh, - Command: baseCommand(cli.NewMockUi()), + cmd := &AgentCommand{ + ShutdownCh: shutdownCh, + BaseCommand: baseCommand(cli.NewMockUi()), } serfAddr := fmt.Sprintf("%s:%d", cfg.BindAddr, cfg.Ports.SerfWan) @@ -371,9 +371,9 @@ func TestProtectDataDir(t *testing.T) { } ui := cli.NewMockUi() - cmd := &Command{ - Command: baseCommand(ui), - args: []string{"-config-file=" + cfgFile.Name()}, + cmd := &AgentCommand{ + BaseCommand: baseCommand(ui), + args: []string{"-config-file=" + cfgFile.Name()}, } if conf := cmd.readConfig(); conf != nil { t.Fatalf("should fail") @@ -395,9 +395,9 @@ func TestBadDataDirPermissions(t *testing.T) { defer os.RemoveAll(dataDir) ui := cli.NewMockUi() - cmd := &Command{ - Command: baseCommand(ui), - args: []string{"-data-dir=" + dataDir, "-server=true"}, + cmd := &AgentCommand{ + BaseCommand: baseCommand(ui), + args: []string{"-data-dir=" + dataDir, "-server=true"}, } if conf := cmd.readConfig(); conf != nil { t.Fatalf("Should fail with bad data directory permissions") diff --git a/command/base/command.go b/command/base.go similarity index 90% rename from command/base/command.go rename to command/base.go index b43184c0ea..2296fd8e09 100644 --- a/command/base/command.go +++ b/command/base.go @@ -1,4 +1,4 @@ -package base +package command import ( "bufio" @@ -28,7 +28,7 @@ const ( FlagSetHTTP = FlagSetClientHTTP | FlagSetServerHTTP ) -type Command struct { +type BaseCommand struct { UI cli.Ui Flags FlagSetFlags @@ -50,7 +50,7 @@ type Command struct { // HTTPClient returns a client with the parsed flags. It panics if the command // does not accept HTTP flags or if the flags have not been parsed. -func (c *Command) HTTPClient() (*api.Client, error) { +func (c *BaseCommand) HTTPClient() (*api.Client, error) { if !c.hasClientHTTP() && !c.hasServerHTTP() { panic("no http flags defined") } @@ -70,26 +70,26 @@ func (c *Command) HTTPClient() (*api.Client, error) { return api.NewClient(config) } -func (c *Command) HTTPAddr() string { +func (c *BaseCommand) HTTPAddr() string { return c.httpAddr.String() } -func (c *Command) HTTPToken() string { +func (c *BaseCommand) HTTPToken() string { return c.token.String() } -func (c *Command) HTTPDatacenter() string { +func (c *BaseCommand) HTTPDatacenter() string { return c.datacenter.String() } -func (c *Command) HTTPStale() bool { +func (c *BaseCommand) HTTPStale() bool { var stale bool c.stale.Merge(&stale) return stale } // httpFlagsClient is the list of flags that apply to HTTP connections. -func (c *Command) httpFlagsClient(f *flag.FlagSet) *flag.FlagSet { +func (c *BaseCommand) httpFlagsClient(f *flag.FlagSet) *flag.FlagSet { if f == nil { f = flag.NewFlagSet("", flag.ContinueOnError) } @@ -124,7 +124,7 @@ func (c *Command) httpFlagsClient(f *flag.FlagSet) *flag.FlagSet { } // httpFlagsServer is the list of flags that apply to HTTP connections. -func (c *Command) httpFlagsServer(f *flag.FlagSet) *flag.FlagSet { +func (c *BaseCommand) httpFlagsServer(f *flag.FlagSet) *flag.FlagSet { if f == nil { f = flag.NewFlagSet("", flag.ContinueOnError) } @@ -143,7 +143,7 @@ func (c *Command) httpFlagsServer(f *flag.FlagSet) *flag.FlagSet { // NewFlagSet creates a new flag set for the given command. It automatically // generates help output and adds the appropriate API flags. -func (c *Command) NewFlagSet(command cli.Command) *flag.FlagSet { +func (c *BaseCommand) NewFlagSet(command cli.Command) *flag.FlagSet { f := flag.NewFlagSet("", flag.ContinueOnError) f.Usage = func() { c.UI.Error(command.Help()) } @@ -171,19 +171,19 @@ func (c *Command) NewFlagSet(command cli.Command) *flag.FlagSet { } // HideFlags is used to set hidden flags that will not be shown in help text -func (c *Command) HideFlags(flags ...string) { +func (c *BaseCommand) HideFlags(flags ...string) { for _, f := range flags { c.hidden.String(f, "", "") } } // Parse is used to parse the underlying flag set. -func (c *Command) Parse(args []string) error { +func (c *BaseCommand) Parse(args []string) error { return c.flagSet.Parse(args) } // Help returns the help for this flagSet. -func (c *Command) Help() string { +func (c *BaseCommand) Help() string { // Some commands with subcommands (kv/snapshot) call this without initializing // any flags first, so exit early to avoid a panic if c.flagSet == nil { @@ -193,12 +193,12 @@ func (c *Command) Help() string { } // hasClientHTTP returns true if this meta command contains client HTTP flags. -func (c *Command) hasClientHTTP() bool { +func (c *BaseCommand) hasClientHTTP() bool { return c.Flags&FlagSetClientHTTP != 0 } // hasServerHTTP returns true if this meta command contains server HTTP flags. -func (c *Command) hasServerHTTP() bool { +func (c *BaseCommand) hasServerHTTP() bool { return c.Flags&FlagSetServerHTTP != 0 } @@ -206,7 +206,7 @@ func (c *Command) hasServerHTTP() bool { // help output. This function is sad because there's no "merging" of command // line flags. We explicitly pull out our "common" options into another section // by doing string comparisons :(. -func (c *Command) helpFlagsFor(f *flag.FlagSet) string { +func (c *BaseCommand) helpFlagsFor(f *flag.FlagSet) string { httpFlagsClient := c.httpFlagsClient(nil) httpFlagsServer := c.httpFlagsServer(nil) diff --git a/commands.go b/command/commands.go similarity index 55% rename from commands.go rename to command/commands.go index e8d3c4f608..d8922be180 100644 --- a/commands.go +++ b/command/commands.go @@ -1,13 +1,10 @@ -package main +package command import ( "os" "os/signal" "syscall" - "github.com/hashicorp/consul/command" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" "github.com/hashicorp/consul/version" "github.com/mitchellh/cli" ) @@ -20,9 +17,9 @@ func init() { Commands = map[string]cli.CommandFactory{ "agent": func() (cli.Command, error) { - return &agent.Command{ - Command: base.Command{ - Flags: base.FlagSetNone, + return &AgentCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetNone, UI: ui, }, Revision: version.GitCommit, @@ -34,314 +31,314 @@ func init() { }, "configtest": func() (cli.Command, error) { - return &command.ConfigTestCommand{ - Command: base.Command{ - Flags: base.FlagSetNone, + return &ConfigTestCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetNone, UI: ui, }, }, nil }, "event": func() (cli.Command, error) { - return &command.EventCommand{ - Command: base.Command{ - Flags: base.FlagSetHTTP, + return &EventCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetHTTP, UI: ui, }, }, nil }, "exec": func() (cli.Command, error) { - return &command.ExecCommand{ + return &ExecCommand{ ShutdownCh: makeShutdownCh(), - Command: base.Command{ - Flags: base.FlagSetHTTP, + BaseCommand: BaseCommand{ + Flags: FlagSetHTTP, UI: ui, }, }, nil }, "force-leave": func() (cli.Command, error) { - return &command.ForceLeaveCommand{ - Command: base.Command{ - Flags: base.FlagSetClientHTTP, + return &ForceLeaveCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetClientHTTP, UI: ui, }, }, nil }, "info": func() (cli.Command, error) { - return &command.InfoCommand{ - Command: base.Command{ + return &InfoCommand{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, }, nil }, "join": func() (cli.Command, error) { - return &command.JoinCommand{ - Command: base.Command{ + return &JoinCommand{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, }, nil }, "keygen": func() (cli.Command, error) { - return &command.KeygenCommand{ - Command: base.Command{ + return &KeygenCommand{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetNone, + Flags: FlagSetNone, }, }, nil }, "keyring": func() (cli.Command, error) { - return &command.KeyringCommand{ - Command: base.Command{ + return &KeyringCommand{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, }, nil }, "kv": func() (cli.Command, error) { - return &command.KVCommand{ - Command: base.Command{ + return &KVCommand{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetNone, + Flags: FlagSetNone, }, }, nil }, "kv delete": func() (cli.Command, error) { - return &command.KVDeleteCommand{ - Command: base.Command{ + return &KVDeleteCommand{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, }, nil }, "kv get": func() (cli.Command, error) { - return &command.KVGetCommand{ - Command: base.Command{ + return &KVGetCommand{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, }, nil }, "kv put": func() (cli.Command, error) { - return &command.KVPutCommand{ - Command: base.Command{ + return &KVPutCommand{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, }, nil }, "kv export": func() (cli.Command, error) { - return &command.KVExportCommand{ - Command: base.Command{ + return &KVExportCommand{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, }, nil }, "kv import": func() (cli.Command, error) { - return &command.KVImportCommand{ - Command: base.Command{ + return &KVImportCommand{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, }, nil }, "leave": func() (cli.Command, error) { - return &command.LeaveCommand{ - Command: base.Command{ - Flags: base.FlagSetClientHTTP, + return &LeaveCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetClientHTTP, UI: ui, }, }, nil }, "lock": func() (cli.Command, error) { - return &command.LockCommand{ + return &LockCommand{ ShutdownCh: makeShutdownCh(), - Command: base.Command{ - Flags: base.FlagSetHTTP, + BaseCommand: BaseCommand{ + Flags: FlagSetHTTP, UI: ui, }, }, nil }, "maint": func() (cli.Command, error) { - return &command.MaintCommand{ - Command: base.Command{ - Flags: base.FlagSetClientHTTP, + return &MaintCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetClientHTTP, UI: ui, }, }, nil }, "members": func() (cli.Command, error) { - return &command.MembersCommand{ - Command: base.Command{ - Flags: base.FlagSetClientHTTP, + return &MembersCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetClientHTTP, UI: ui, }, }, nil }, "monitor": func() (cli.Command, error) { - return &command.MonitorCommand{ + return &MonitorCommand{ ShutdownCh: makeShutdownCh(), - Command: base.Command{ - Flags: base.FlagSetClientHTTP, + BaseCommand: BaseCommand{ + Flags: FlagSetClientHTTP, UI: ui, }, }, nil }, "operator": func() (cli.Command, error) { - return &command.OperatorCommand{ - Command: base.Command{ - Flags: base.FlagSetNone, + return &OperatorCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetNone, UI: ui, }, }, nil }, "operator autopilot": func() (cli.Command, error) { - return &command.OperatorAutopilotCommand{ - Command: base.Command{ - Flags: base.FlagSetNone, + return &OperatorAutopilotCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetNone, UI: ui, }, }, nil }, "operator autopilot get-config": func() (cli.Command, error) { - return &command.OperatorAutopilotGetCommand{ - Command: base.Command{ - Flags: base.FlagSetHTTP, + return &OperatorAutopilotGetCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetHTTP, UI: ui, }, }, nil }, "operator autopilot set-config": func() (cli.Command, error) { - return &command.OperatorAutopilotSetCommand{ - Command: base.Command{ - Flags: base.FlagSetHTTP, + return &OperatorAutopilotSetCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetHTTP, UI: ui, }, }, nil }, "operator raft": func() (cli.Command, error) { - return &command.OperatorRaftCommand{ - Command: base.Command{ - Flags: base.FlagSetHTTP, + return &OperatorRaftCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetHTTP, UI: ui, }, }, nil }, "operator raft list-peers": func() (cli.Command, error) { - return &command.OperatorRaftListCommand{ - Command: base.Command{ - Flags: base.FlagSetHTTP, + return &OperatorRaftListCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetHTTP, UI: ui, }, }, nil }, "operator raft remove-peer": func() (cli.Command, error) { - return &command.OperatorRaftRemoveCommand{ - Command: base.Command{ - Flags: base.FlagSetHTTP, + return &OperatorRaftRemoveCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetHTTP, UI: ui, }, }, nil }, "reload": func() (cli.Command, error) { - return &command.ReloadCommand{ - Command: base.Command{ - Flags: base.FlagSetClientHTTP, + return &ReloadCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetClientHTTP, UI: ui, }, }, nil }, "rtt": func() (cli.Command, error) { - return &command.RTTCommand{ - Command: base.Command{ - Flags: base.FlagSetClientHTTP, + return &RTTCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetClientHTTP, UI: ui, }, }, nil }, "snapshot": func() (cli.Command, error) { - return &command.SnapshotCommand{ + return &SnapshotCommand{ UI: ui, }, nil }, "snapshot restore": func() (cli.Command, error) { - return &command.SnapshotRestoreCommand{ - Command: base.Command{ - Flags: base.FlagSetHTTP, + return &SnapshotRestoreCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetHTTP, UI: ui, }, }, nil }, "snapshot save": func() (cli.Command, error) { - return &command.SnapshotSaveCommand{ - Command: base.Command{ - Flags: base.FlagSetHTTP, + return &SnapshotSaveCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetHTTP, UI: ui, }, }, nil }, "snapshot inspect": func() (cli.Command, error) { - return &command.SnapshotInspectCommand{ - Command: base.Command{ - Flags: base.FlagSetNone, + return &SnapshotInspectCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetNone, UI: ui, }, }, nil }, "validate": func() (cli.Command, error) { - return &command.ValidateCommand{ - Command: base.Command{ - Flags: base.FlagSetNone, + return &ValidateCommand{ + BaseCommand: BaseCommand{ + Flags: FlagSetNone, UI: ui, }, }, nil }, "version": func() (cli.Command, error) { - return &command.VersionCommand{ + return &VersionCommand{ HumanVersion: version.GetHumanVersion(), UI: ui, }, nil }, "watch": func() (cli.Command, error) { - return &command.WatchCommand{ + return &WatchCommand{ ShutdownCh: makeShutdownCh(), - Command: base.Command{ - Flags: base.FlagSetHTTP, + BaseCommand: BaseCommand{ + Flags: FlagSetHTTP, UI: ui, }, }, nil diff --git a/command/base/config_util.go b/command/config_util.go similarity index 99% rename from command/base/config_util.go rename to command/config_util.go index fec791e9c6..82ea430e6e 100644 --- a/command/base/config_util.go +++ b/command/config_util.go @@ -1,4 +1,4 @@ -package base +package command import ( "fmt" diff --git a/command/base/config_util_test.go b/command/config_util_test.go similarity index 97% rename from command/base/config_util_test.go rename to command/config_util_test.go index 0fc3ae6a71..46144c52d6 100644 --- a/command/base/config_util_test.go +++ b/command/config_util_test.go @@ -1,4 +1,4 @@ -package base +package command import ( "bytes" @@ -7,9 +7,10 @@ import ( "strings" "testing" - "github.com/mitchellh/mapstructure" "path" "reflect" + + "github.com/mitchellh/mapstructure" ) func TestConfigUtil_Values(t *testing.T) { @@ -107,7 +108,7 @@ func TestConfigUtil_Visit(t *testing.T) { return nil } - basePath := "../../test/command/merge" + basePath := "../test/command/merge" if err := Visit(basePath, visitor); err != nil { t.Fatalf("err: %v", err) } diff --git a/command/configtest.go b/command/configtest.go index e4074fee8f..2194b16ee7 100644 --- a/command/configtest.go +++ b/command/configtest.go @@ -4,14 +4,13 @@ import ( "fmt" "strings" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" ) // ConfigTestCommand is a Command implementation that is used to // verify config files type ConfigTestCommand struct { - base.Command + BaseCommand } func (c *ConfigTestCommand) Help() string { @@ -28,7 +27,7 @@ Usage: consul configtest [options] Returns 0 if the configuration is valid, or 1 if there are problems. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -36,14 +35,14 @@ Usage: consul configtest [options] func (c *ConfigTestCommand) Run(args []string) int { var configFiles []string - f := c.Command.NewFlagSet(c) - f.Var((*agent.AppendSliceValue)(&configFiles), "config-file", + f := c.BaseCommand.NewFlagSet(c) + f.Var((*AppendSliceValue)(&configFiles), "config-file", "Path to a JSON file to read configuration from. This can be specified multiple times.") - f.Var((*agent.AppendSliceValue)(&configFiles), "config-dir", + f.Var((*AppendSliceValue)(&configFiles), "config-dir", "Path to a directory to read configuration files from. This will read every file ending in "+ ".json as configuration in this directory in alphabetical order.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } diff --git a/command/configtest_test.go b/command/configtest_test.go index 29d0fbf12f..a1dbf857de 100644 --- a/command/configtest_test.go +++ b/command/configtest_test.go @@ -6,7 +6,6 @@ import ( "path/filepath" "testing" - "github.com/hashicorp/consul/command/base" "github.com/hashicorp/consul/testutil" "github.com/mitchellh/cli" ) @@ -14,9 +13,9 @@ import ( func testConfigTestCommand(t *testing.T) (*cli.MockUi, *ConfigTestCommand) { ui := cli.NewMockUi() return ui, &ConfigTestCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetNone, + Flags: FlagSetNone, }, } } diff --git a/command/event.go b/command/event.go index faa39f98ea..13d5749022 100644 --- a/command/event.go +++ b/command/event.go @@ -6,13 +6,12 @@ import ( "strings" consulapi "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" ) // EventCommand is a Command implementation that is used to // fire new events type EventCommand struct { - base.Command + BaseCommand } func (c *EventCommand) Help() string { @@ -23,7 +22,7 @@ Usage: consul event [options] [payload] a name, but a payload is optional. Events support filtering using regular expressions on node name, service, and tag definitions. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -31,7 +30,7 @@ Usage: consul event [options] [payload] func (c *EventCommand) Run(args []string) int { var name, node, service, tag string - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) f.StringVar(&name, "name", "", "Name of the event.") f.StringVar(&node, "node", "", @@ -41,7 +40,7 @@ func (c *EventCommand) Run(args []string) int { f.StringVar(&tag, "tag", "", "Regular expression to filter on service tags. Must be used with -service.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -92,7 +91,7 @@ func (c *EventCommand) Run(args []string) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/event_test.go b/command/event_test.go index a5ff27b04b..478a88fda6 100644 --- a/command/event_test.go +++ b/command/event_test.go @@ -4,8 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) @@ -21,9 +20,9 @@ func TestEventCommandRun(t *testing.T) { ui := cli.NewMockUi() c := &EventCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, } args := []string{"-http-addr=" + a1.HTTPAddr(), "-name=cmd"} diff --git a/command/exec.go b/command/exec.go index 45729e63d5..826638153b 100644 --- a/command/exec.go +++ b/command/exec.go @@ -14,7 +14,6 @@ import ( "unicode" consulapi "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" "github.com/mitchellh/cli" ) @@ -116,7 +115,7 @@ type rExecExit struct { // ExecCommand is a Command implementation that is used to // do remote execution of commands type ExecCommand struct { - base.Command + BaseCommand ShutdownCh <-chan struct{} conf rExecConf @@ -126,7 +125,7 @@ type ExecCommand struct { } func (c *ExecCommand) Run(args []string) int { - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) f.StringVar(&c.conf.node, "node", "", "Regular expression to filter on node names.") f.StringVar(&c.conf.service, "service", "", @@ -143,7 +142,7 @@ func (c *ExecCommand) Run(args []string) int { f.BoolVar(&c.conf.verbose, "verbose", false, "Enables verbose output.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -179,7 +178,7 @@ func (c *ExecCommand) Run(args []string) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 @@ -192,7 +191,7 @@ func (c *ExecCommand) Run(args []string) int { c.client = client // Check if this is a foreign datacenter - if c.Command.HTTPDatacenter() != "" && c.Command.HTTPDatacenter() != info["Config"]["Datacenter"] { + if c.BaseCommand.HTTPDatacenter() != "" && c.BaseCommand.HTTPDatacenter() != info["Config"]["Datacenter"] { if c.conf.verbose { c.UI.Info("Remote exec in foreign datacenter, using Session TTL") } @@ -492,7 +491,7 @@ func (c *ExecCommand) createSessionForeign() (string, error) { node := services[0].Node.Node if c.conf.verbose { c.UI.Info(fmt.Sprintf("Binding session to remote node %s@%s", - node, c.Command.HTTPDatacenter())) + node, c.BaseCommand.HTTPDatacenter())) } session := c.client.Session() @@ -621,7 +620,7 @@ Usage: consul exec [options] [-|command...] definitions. If a command is '-', stdin will be read until EOF and used as a script input. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } diff --git a/command/exec_test.go b/command/exec_test.go index 00a7cca645..0029734d2b 100644 --- a/command/exec_test.go +++ b/command/exec_test.go @@ -6,9 +6,8 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent" consulapi "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" "github.com/hashicorp/consul/testutil/retry" "github.com/mitchellh/cli" ) @@ -16,9 +15,9 @@ import ( func testExecCommand(t *testing.T) (*cli.MockUi, *ExecCommand) { ui := cli.NewMockUi() return ui, &ExecCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } } diff --git a/command/agent/flag_slice_value.go b/command/flag_slice_value.go similarity index 96% rename from command/agent/flag_slice_value.go rename to command/flag_slice_value.go index 7a3862a391..eee4770161 100644 --- a/command/agent/flag_slice_value.go +++ b/command/flag_slice_value.go @@ -1,4 +1,4 @@ -package agent +package command import "strings" diff --git a/command/agent/flag_slice_value_test.go b/command/flag_slice_value_test.go similarity index 97% rename from command/agent/flag_slice_value_test.go rename to command/flag_slice_value_test.go index 6a88168482..59d1074e24 100644 --- a/command/agent/flag_slice_value_test.go +++ b/command/flag_slice_value_test.go @@ -1,4 +1,4 @@ -package agent +package command import ( "flag" diff --git a/command/force_leave.go b/command/force_leave.go index 6c32e22a1d..42fbcad8d2 100644 --- a/command/force_leave.go +++ b/command/force_leave.go @@ -2,19 +2,18 @@ package command import ( "fmt" - "github.com/hashicorp/consul/command/base" "strings" ) // ForceLeaveCommand is a Command implementation that tells a running Consul // to force a member to enter the "left" state. type ForceLeaveCommand struct { - base.Command + BaseCommand } func (c *ForceLeaveCommand) Run(args []string) int { - f := c.Command.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + f := c.BaseCommand.NewFlagSet(c) + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -26,7 +25,7 @@ func (c *ForceLeaveCommand) Run(args []string) int { return 1 } - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 @@ -56,7 +55,7 @@ Usage: consul force-leave [options] name Consul will attempt to reconnect to those failed nodes for some period of time before eventually reaping them. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } diff --git a/command/force_leave_test.go b/command/force_leave_test.go index 8aeec13ab4..0f1750dbf5 100644 --- a/command/force_leave_test.go +++ b/command/force_leave_test.go @@ -5,8 +5,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/serf/serf" "github.com/mitchellh/cli" @@ -15,9 +14,9 @@ import ( func testForceLeaveCommand(t *testing.T) (*cli.MockUi, *ForceLeaveCommand) { ui := cli.NewMockUi() return ui, &ForceLeaveCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, } } diff --git a/command/info.go b/command/info.go index 33b469fc90..8ba6f44c2a 100644 --- a/command/info.go +++ b/command/info.go @@ -4,14 +4,12 @@ import ( "fmt" "sort" "strings" - - "github.com/hashicorp/consul/command/base" ) // InfoCommand is a Command implementation that queries a running // Consul agent for various debugging statistics for operators type InfoCommand struct { - base.Command + BaseCommand } func (c *InfoCommand) Help() string { @@ -20,19 +18,19 @@ Usage: consul info [options] Provides debugging information for operators -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } func (c *InfoCommand) Run(args []string) int { - c.Command.NewFlagSet(c) + c.BaseCommand.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/info_test.go b/command/info_test.go index 6f3acb502a..13918250d7 100644 --- a/command/info_test.go +++ b/command/info_test.go @@ -4,8 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) @@ -21,9 +20,9 @@ func TestInfoCommandRun(t *testing.T) { ui := cli.NewMockUi() c := &InfoCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, } args := []string{"-http-addr=" + a1.HTTPAddr()} diff --git a/command/join.go b/command/join.go index d71b94fa42..df042791c4 100644 --- a/command/join.go +++ b/command/join.go @@ -2,14 +2,13 @@ package command import ( "fmt" - "github.com/hashicorp/consul/command/base" "strings" ) // JoinCommand is a Command implementation that tells a running Consul // agent to join another. type JoinCommand struct { - base.Command + BaseCommand } func (c *JoinCommand) Help() string { @@ -19,7 +18,7 @@ Usage: consul join [options] address ... Tells a running Consul agent (with "consul agent") to join the cluster by specifying at least one existing member. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -27,9 +26,9 @@ Usage: consul join [options] address ... func (c *JoinCommand) Run(args []string) int { var wan bool - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) f.BoolVar(&wan, "wan", false, "Joins a server to another server in the WAN pool.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -41,7 +40,7 @@ func (c *JoinCommand) Run(args []string) int { return 1 } - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/join_test.go b/command/join_test.go index fbf3756347..3db03ac036 100644 --- a/command/join_test.go +++ b/command/join_test.go @@ -5,17 +5,16 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) func testJoinCommand(t *testing.T) (*cli.MockUi, *JoinCommand) { ui := cli.NewMockUi() return ui, &JoinCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, } } diff --git a/command/keygen.go b/command/keygen.go index dba04478d0..6506d5b1e4 100644 --- a/command/keygen.go +++ b/command/keygen.go @@ -5,19 +5,17 @@ import ( "encoding/base64" "fmt" "strings" - - "github.com/hashicorp/consul/command/base" ) // KeygenCommand is a Command implementation that generates an encryption // key for use in `consul agent`. type KeygenCommand struct { - base.Command + BaseCommand } func (c *KeygenCommand) Run(args []string) int { - c.Command.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + c.BaseCommand.NewFlagSet(c) + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -48,7 +46,7 @@ Usage: consul keygen agent to encrypt traffic. The output of this command is already in the proper format that the agent expects. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } diff --git a/command/keygen_test.go b/command/keygen_test.go index 481bdc7c2e..5ddca527ed 100644 --- a/command/keygen_test.go +++ b/command/keygen_test.go @@ -4,7 +4,6 @@ import ( "encoding/base64" "testing" - "github.com/hashicorp/consul/command/base" "github.com/mitchellh/cli" ) @@ -17,9 +16,9 @@ func TestKeygenCommand(t *testing.T) { t.Parallel() ui := cli.NewMockUi() c := &KeygenCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetNone, + Flags: FlagSetNone, }, } code := c.Run(nil) diff --git a/command/keyring.go b/command/keyring.go index b93e937871..5ca1a4862f 100644 --- a/command/keyring.go +++ b/command/keyring.go @@ -4,16 +4,15 @@ import ( "fmt" "strings" + "github.com/hashicorp/consul/agent" consulapi "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" "github.com/mitchellh/cli" ) // KeyringCommand is a Command implementation that handles querying, installing, // and removing gossip encryption keys from a keyring. type KeyringCommand struct { - base.Command + BaseCommand } func (c *KeyringCommand) Run(args []string) int { @@ -21,7 +20,7 @@ func (c *KeyringCommand) Run(args []string) int { var listKeys bool var relay int - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) f.StringVar(&installKey, "install", "", "Install a new encryption key. This will broadcast the new key to "+ @@ -40,7 +39,7 @@ func (c *KeyringCommand) Run(args []string) int { "to the operation through this many randomly-chosen other nodes in the "+ "cluster. The maximum allowed value is 5.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -75,7 +74,7 @@ func (c *KeyringCommand) Run(args []string) int { } // All other operations will require a client connection - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 @@ -159,7 +158,7 @@ Usage: consul keyring [options] are no errors. If any node fails to reply or reports failure, the exit code will be 1. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } diff --git a/command/keyring_test.go b/command/keyring_test.go index f664aaea9d..73c6f5c489 100644 --- a/command/keyring_test.go +++ b/command/keyring_test.go @@ -4,17 +4,16 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) func testKeyringCommand(t *testing.T) (*cli.MockUi, *KeyringCommand) { ui := cli.NewMockUi() return ui, &KeyringCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, } } diff --git a/command/kv_command.go b/command/kv_command.go index 5e6e0461c4..da7183baa4 100644 --- a/command/kv_command.go +++ b/command/kv_command.go @@ -3,14 +3,13 @@ package command import ( "strings" - "github.com/hashicorp/consul/command/base" "github.com/mitchellh/cli" ) // KVCommand is a Command implementation that just shows help for // the subcommands nested below it. type KVCommand struct { - base.Command + BaseCommand } func (c *KVCommand) Run(args []string) int { diff --git a/command/kv_delete.go b/command/kv_delete.go index ec3c0fa9da..ed0b05e893 100644 --- a/command/kv_delete.go +++ b/command/kv_delete.go @@ -5,13 +5,12 @@ import ( "strings" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" ) // KVDeleteCommand is a Command implementation that is used to delete a key or // prefix of keys from the key-value store. type KVDeleteCommand struct { - base.Command + BaseCommand } func (c *KVDeleteCommand) Help() string { @@ -32,13 +31,13 @@ Usage: consul kv delete [options] KEY_OR_PREFIX This will delete the keys named "foo", "food", and "foo/bar/zip" if they existed. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } func (c *KVDeleteCommand) Run(args []string) int { - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) cas := f.Bool("cas", false, "Perform a Check-And-Set operation. Specifying this value also requires "+ "the -modify-index flag to be set. The default value is false.") @@ -48,7 +47,7 @@ func (c *KVDeleteCommand) Run(args []string) int { recurse := f.Bool("recurse", false, "Recursively delete all keys with the path. The default value is false.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -98,7 +97,7 @@ func (c *KVDeleteCommand) Run(args []string) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/kv_delete_test.go b/command/kv_delete_test.go index a2fa9aba0e..dbe1991bf3 100644 --- a/command/kv_delete_test.go +++ b/command/kv_delete_test.go @@ -5,18 +5,17 @@ import ( "strings" "testing" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" "github.com/mitchellh/cli" ) func testKVDeleteCommand(t *testing.T) (*cli.MockUi, *KVDeleteCommand) { ui := cli.NewMockUi() return ui, &KVDeleteCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } } diff --git a/command/kv_export.go b/command/kv_export.go index 359d8cd84c..bd7531e3bb 100644 --- a/command/kv_export.go +++ b/command/kv_export.go @@ -7,13 +7,12 @@ import ( "strings" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" ) // KVExportCommand is a Command implementation that is used to export // a KV tree as JSON type KVExportCommand struct { - base.Command + BaseCommand } func (c *KVExportCommand) Synopsis() string { @@ -32,14 +31,14 @@ Usage: consul kv export [KEY_OR_PREFIX] For a full list of options and examples, please see the Consul documentation. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } func (c *KVExportCommand) Run(args []string) int { - f := c.Command.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + f := c.BaseCommand.NewFlagSet(c) + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -64,14 +63,14 @@ func (c *KVExportCommand) Run(args []string) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 } pairs, _, err := client.KV().List(key, &api.QueryOptions{ - AllowStale: c.Command.HTTPStale(), + AllowStale: c.BaseCommand.HTTPStale(), }) if err != nil { c.UI.Error(fmt.Sprintf("Error querying Consul agent: %s", err)) diff --git a/command/kv_export_test.go b/command/kv_export_test.go index baf797df86..fd9a6cb28e 100644 --- a/command/kv_export_test.go +++ b/command/kv_export_test.go @@ -5,9 +5,8 @@ import ( "encoding/json" "testing" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" "github.com/mitchellh/cli" ) @@ -19,9 +18,9 @@ func TestKVExportCommand_Run(t *testing.T) { ui := cli.NewMockUi() c := KVExportCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } diff --git a/command/kv_get.go b/command/kv_get.go index de3f1ee97e..ef83aeb69c 100644 --- a/command/kv_get.go +++ b/command/kv_get.go @@ -9,13 +9,12 @@ import ( "text/tabwriter" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" ) // KVGetCommand is a Command implementation that is used to fetch the value of // a key from the key-value store. type KVGetCommand struct { - base.Command + BaseCommand } func (c *KVGetCommand) Help() string { @@ -50,13 +49,13 @@ Usage: consul kv get [options] [KEY_OR_PREFIX] For a full list of options and examples, please see the Consul documentation. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } func (c *KVGetCommand) Run(args []string) int { - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) base64encode := f.Bool("base64", false, "Base64 encode the value. The default value is false.") detailed := f.Bool("detailed", false, @@ -75,7 +74,7 @@ func (c *KVGetCommand) Run(args []string) int { "String to use as a separator between keys. The default value is \"/\", "+ "but this option is only taken into account when paired with the -keys flag.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -108,7 +107,7 @@ func (c *KVGetCommand) Run(args []string) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 @@ -117,7 +116,7 @@ func (c *KVGetCommand) Run(args []string) int { switch { case *keys: keys, _, err := client.KV().Keys(key, *separator, &api.QueryOptions{ - AllowStale: c.Command.HTTPStale(), + AllowStale: c.BaseCommand.HTTPStale(), }) if err != nil { c.UI.Error(fmt.Sprintf("Error querying Consul agent: %s", err)) @@ -131,7 +130,7 @@ func (c *KVGetCommand) Run(args []string) int { return 0 case *recurse: pairs, _, err := client.KV().List(key, &api.QueryOptions{ - AllowStale: c.Command.HTTPStale(), + AllowStale: c.BaseCommand.HTTPStale(), }) if err != nil { c.UI.Error(fmt.Sprintf("Error querying Consul agent: %s", err)) @@ -163,7 +162,7 @@ func (c *KVGetCommand) Run(args []string) int { return 0 default: pair, _, err := client.KV().Get(key, &api.QueryOptions{ - AllowStale: c.Command.HTTPStale(), + AllowStale: c.BaseCommand.HTTPStale(), }) if err != nil { c.UI.Error(fmt.Sprintf("Error querying Consul agent: %s", err)) diff --git a/command/kv_get_test.go b/command/kv_get_test.go index ad994d5e4b..f3078c67a3 100644 --- a/command/kv_get_test.go +++ b/command/kv_get_test.go @@ -5,18 +5,17 @@ import ( "strings" "testing" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" "github.com/mitchellh/cli" ) func testKVGetCommand(t *testing.T) (*cli.MockUi, *KVGetCommand) { ui := cli.NewMockUi() return ui, &KVGetCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } } diff --git a/command/kv_import.go b/command/kv_import.go index ec7247ba86..aa47f316a7 100644 --- a/command/kv_import.go +++ b/command/kv_import.go @@ -12,13 +12,12 @@ import ( "strings" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" ) // KVImportCommand is a Command implementation that is used to import // a KV tree stored as JSON type KVImportCommand struct { - base.Command + BaseCommand // testStdin is the input for testing. testStdin io.Reader @@ -49,15 +48,15 @@ Usage: consul kv import [DATA] For a full list of options and examples, please see the Consul documentation. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } func (c *KVImportCommand) Run(args []string) int { - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -70,7 +69,7 @@ func (c *KVImportCommand) Run(args []string) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/kv_import_test.go b/command/kv_import_test.go index 5cc273a743..2356395235 100644 --- a/command/kv_import_test.go +++ b/command/kv_import_test.go @@ -4,8 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) @@ -30,9 +29,9 @@ func TestKVImportCommand_Run(t *testing.T) { ui := cli.NewMockUi() c := &KVImportCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, testStdin: strings.NewReader(json), } diff --git a/command/kv_put.go b/command/kv_put.go index efd2aa7282..45db2e344d 100644 --- a/command/kv_put.go +++ b/command/kv_put.go @@ -10,13 +10,12 @@ import ( "strings" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" ) // KVPutCommand is a Command implementation that is used to write data to the // key-value store. type KVPutCommand struct { - base.Command + BaseCommand // testStdin is the input for testing. testStdin io.Reader @@ -56,13 +55,13 @@ Usage: consul kv put [options] KEY [DATA] Additional flags and more advanced use cases are detailed below. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } func (c *KVPutCommand) Run(args []string) int { - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) cas := f.Bool("cas", false, "Perform a Check-And-Set operation. Specifying this value also "+ "requires the -modify-index flag to be set. The default value "+ @@ -89,7 +88,7 @@ func (c *KVPutCommand) Run(args []string) int { "-session flag to be set. The key must be held by the session in order to "+ "be unlocked. The default value is false.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -122,7 +121,7 @@ func (c *KVPutCommand) Run(args []string) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/kv_put_test.go b/command/kv_put_test.go index 89103e663e..3f105adf22 100644 --- a/command/kv_put_test.go +++ b/command/kv_put_test.go @@ -9,9 +9,8 @@ import ( "strings" "testing" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" "github.com/hashicorp/consul/testutil" "github.com/mitchellh/cli" ) @@ -19,9 +18,9 @@ import ( func testKVPutCommand(t *testing.T) (*cli.MockUi, *KVPutCommand) { ui := cli.NewMockUi() return ui, &KVPutCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } } diff --git a/command/leave.go b/command/leave.go index 5912f125bb..e747d188ad 100644 --- a/command/leave.go +++ b/command/leave.go @@ -2,14 +2,13 @@ package command import ( "fmt" - "github.com/hashicorp/consul/command/base" "strings" ) // LeaveCommand is a Command implementation that instructs // the Consul agent to gracefully leave the cluster type LeaveCommand struct { - base.Command + BaseCommand } func (c *LeaveCommand) Help() string { @@ -18,14 +17,14 @@ Usage: consul leave [options] Causes the agent to gracefully leave the Consul cluster and shutdown. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } func (c *LeaveCommand) Run(args []string) int { - f := c.Command.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + f := c.BaseCommand.NewFlagSet(c) + if err := c.BaseCommand.Parse(args); err != nil { return 1 } nonFlagArgs := f.Args() @@ -35,7 +34,7 @@ func (c *LeaveCommand) Run(args []string) int { return 1 } - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/leave_test.go b/command/leave_test.go index 4e82fa98ac..61e0915f6b 100644 --- a/command/leave_test.go +++ b/command/leave_test.go @@ -4,17 +4,16 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) func testLeaveCommand(t *testing.T) (*cli.MockUi, *LeaveCommand) { ui := cli.NewMockUi() return ui, &LeaveCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, } } diff --git a/command/lock.go b/command/lock.go index 8ca05f39e6..f7198fc6e1 100644 --- a/command/lock.go +++ b/command/lock.go @@ -9,9 +9,8 @@ import ( "syscall" "time" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" ) const ( @@ -36,7 +35,7 @@ const ( // LockCommand is a Command implementation that is used to setup // a "lock" which manages lock acquisition and invokes a sub-process type LockCommand struct { - base.Command + BaseCommand ShutdownCh <-chan struct{} @@ -65,7 +64,7 @@ Usage: consul lock [options] prefix child... The prefix provided must have write privileges. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -83,7 +82,7 @@ func (c *LockCommand) run(args []string, lu **LockUnlock) int { var passStdin bool var timeout time.Duration - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) f.IntVar(&limit, "n", 1, "Optional limit on the number of concurrent lock holders. The underlying "+ "implementation switches from a lock to a semaphore when the value is "+ @@ -109,7 +108,7 @@ func (c *LockCommand) run(args []string, lu **LockUnlock) int { f.DurationVar(&timeout, "try", 0, "DEPRECATED. Use -timeout instead.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -149,7 +148,7 @@ func (c *LockCommand) run(args []string, lu **LockUnlock) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/lock_test.go b/command/lock_test.go index 34988c3695..27e8d36167 100644 --- a/command/lock_test.go +++ b/command/lock_test.go @@ -8,18 +8,17 @@ import ( "testing" "time" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" "github.com/mitchellh/cli" ) func testLockCommand(t *testing.T) (*cli.MockUi, *LockCommand) { ui := cli.NewMockUi() return ui, &LockCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } } diff --git a/command/maint.go b/command/maint.go index eed14c2808..831b2d2e07 100644 --- a/command/maint.go +++ b/command/maint.go @@ -3,14 +3,12 @@ package command import ( "fmt" "strings" - - "github.com/hashicorp/consul/command/base" ) // MaintCommand is a Command implementation that enables or disables // node or service maintenance mode. type MaintCommand struct { - base.Command + BaseCommand } func (c *MaintCommand) Help() string { @@ -38,7 +36,7 @@ Usage: consul maint [options] If no arguments are given, the agent's maintenance status will be shown. This will return blank if nothing is currently under maintenance. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -49,14 +47,14 @@ func (c *MaintCommand) Run(args []string) int { var reason string var serviceID string - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) f.BoolVar(&enable, "enable", false, "Enable maintenance mode.") f.BoolVar(&disable, "disable", false, "Disable maintenance mode.") f.StringVar(&reason, "reason", "", "Text describing the maintenance reason.") f.StringVar(&serviceID, "service", "", "Control maintenance mode for a specific service ID.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -75,7 +73,7 @@ func (c *MaintCommand) Run(args []string) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/maint_test.go b/command/maint_test.go index 87527f1794..b9e7bfc8be 100644 --- a/command/maint_test.go +++ b/command/maint_test.go @@ -4,18 +4,17 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/mitchellh/cli" ) func testMaintCommand(t *testing.T) (*cli.MockUi, *MaintCommand) { ui := cli.NewMockUi() return ui, &MaintCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, } } diff --git a/command/members.go b/command/members.go index f907d34af2..631d1c08b3 100644 --- a/command/members.go +++ b/command/members.go @@ -8,7 +8,6 @@ import ( "strings" consulapi "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" "github.com/hashicorp/serf/serf" "github.com/ryanuber/columnize" ) @@ -16,7 +15,7 @@ import ( // MembersCommand is a Command implementation that queries a running // Consul agent what members are part of the cluster currently. type MembersCommand struct { - base.Command + BaseCommand } func (c *MembersCommand) Help() string { @@ -25,7 +24,7 @@ Usage: consul members [options] Outputs the members of a running Consul agent. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -35,7 +34,7 @@ func (c *MembersCommand) Run(args []string) int { var wan bool var statusFilter string - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) f.BoolVar(&detailed, "detailed", false, "Provides detailed information about nodes.") f.BoolVar(&wan, "wan", false, @@ -45,7 +44,7 @@ func (c *MembersCommand) Run(args []string) int { "If provided, output is filtered to only nodes matching the regular "+ "expression for status.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -56,7 +55,7 @@ func (c *MembersCommand) Run(args []string) int { return 1 } - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/members_test.go b/command/members_test.go index 6ecd8bb258..e48bd124e2 100644 --- a/command/members_test.go +++ b/command/members_test.go @@ -5,17 +5,16 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) func testMembersCommand(t *testing.T) (*cli.MockUi, *MembersCommand) { ui := cli.NewMockUi() return ui, &MembersCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, } } diff --git a/command/monitor.go b/command/monitor.go index 469d926084..63c87b1961 100644 --- a/command/monitor.go +++ b/command/monitor.go @@ -4,14 +4,12 @@ import ( "fmt" "strings" "sync" - - "github.com/hashicorp/consul/command/base" ) // MonitorCommand is a Command implementation that queries a running // Consul agent what members are part of the cluster currently. type MonitorCommand struct { - base.Command + BaseCommand ShutdownCh <-chan struct{} @@ -29,7 +27,7 @@ Usage: consul monitor [options] example your agent may only be logging at INFO level, but with the monitor you can see the DEBUG level logs. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -37,14 +35,14 @@ Usage: consul monitor [options] func (c *MonitorCommand) Run(args []string) int { var logLevel string - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) f.StringVar(&logLevel, "log-level", "INFO", "Log level of the agent.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/operator.go b/command/operator.go index b9189a3059..1272d7898c 100644 --- a/command/operator.go +++ b/command/operator.go @@ -3,14 +3,13 @@ package command import ( "strings" - "github.com/hashicorp/consul/command/base" "github.com/mitchellh/cli" ) // OperatorCommand is used to provide various low-level tools for Consul // operators. type OperatorCommand struct { - base.Command + BaseCommand } func (c *OperatorCommand) Help() string { diff --git a/command/operator_autopilot.go b/command/operator_autopilot.go index c187fa6a4f..5823739f53 100644 --- a/command/operator_autopilot.go +++ b/command/operator_autopilot.go @@ -3,12 +3,11 @@ package command import ( "strings" - "github.com/hashicorp/consul/command/base" "github.com/mitchellh/cli" ) type OperatorAutopilotCommand struct { - base.Command + BaseCommand } func (c *OperatorAutopilotCommand) Help() string { diff --git a/command/operator_autopilot_get.go b/command/operator_autopilot_get.go index 05ea24b9db..d8dc59f83d 100644 --- a/command/operator_autopilot_get.go +++ b/command/operator_autopilot_get.go @@ -6,11 +6,10 @@ import ( "strings" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" ) type OperatorAutopilotGetCommand struct { - base.Command + BaseCommand } func (c *OperatorAutopilotGetCommand) Help() string { @@ -19,7 +18,7 @@ Usage: consul operator autopilot get-config [options] Displays the current Autopilot configuration. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -29,9 +28,9 @@ func (c *OperatorAutopilotGetCommand) Synopsis() string { } func (c *OperatorAutopilotGetCommand) Run(args []string) int { - c.Command.NewFlagSet(c) + c.BaseCommand.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { if err == flag.ErrHelp { return 0 } @@ -40,7 +39,7 @@ func (c *OperatorAutopilotGetCommand) Run(args []string) int { } // Set up a client. - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error initializing client: %s", err)) return 1 @@ -48,7 +47,7 @@ func (c *OperatorAutopilotGetCommand) Run(args []string) int { // Fetch the current configuration. opts := &api.QueryOptions{ - AllowStale: c.Command.HTTPStale(), + AllowStale: c.BaseCommand.HTTPStale(), } config, err := client.Operator().AutopilotGetConfiguration(opts) if err != nil { diff --git a/command/operator_autopilot_get_test.go b/command/operator_autopilot_get_test.go index 9ec7ebb6e9..e2e4fba1db 100644 --- a/command/operator_autopilot_get_test.go +++ b/command/operator_autopilot_get_test.go @@ -4,8 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) @@ -21,9 +20,9 @@ func TestOperator_Autopilot_Get(t *testing.T) { ui := cli.NewMockUi() c := OperatorAutopilotGetCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } args := []string{"-http-addr=" + a.HTTPAddr()} diff --git a/command/operator_autopilot_set.go b/command/operator_autopilot_set.go index 712cc6e129..621360fc9f 100644 --- a/command/operator_autopilot_set.go +++ b/command/operator_autopilot_set.go @@ -7,11 +7,10 @@ import ( "time" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" ) type OperatorAutopilotSetCommand struct { - base.Command + BaseCommand } func (c *OperatorAutopilotSetCommand) Help() string { @@ -20,7 +19,7 @@ Usage: consul operator autopilot set-config [options] Modifies the current Autopilot configuration. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -30,14 +29,14 @@ func (c *OperatorAutopilotSetCommand) Synopsis() string { } func (c *OperatorAutopilotSetCommand) Run(args []string) int { - var cleanupDeadServers base.BoolValue - var maxTrailingLogs base.UintValue - var lastContactThreshold base.DurationValue - var serverStabilizationTime base.DurationValue - var redundancyZoneTag base.StringValue - var disableUpgradeMigration base.BoolValue + var cleanupDeadServers BoolValue + var maxTrailingLogs UintValue + var lastContactThreshold DurationValue + var serverStabilizationTime DurationValue + var redundancyZoneTag StringValue + var disableUpgradeMigration BoolValue - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) f.Var(&cleanupDeadServers, "cleanup-dead-servers", "Controls whether Consul will automatically remove dead servers "+ @@ -61,7 +60,7 @@ func (c *OperatorAutopilotSetCommand) Run(args []string) int { "(Enterprise-only) Controls whether Consul will avoid promoting new servers until "+ "it can perform a migration. Must be one of `true|false`.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { if err == flag.ErrHelp { return 0 } @@ -70,7 +69,7 @@ func (c *OperatorAutopilotSetCommand) Run(args []string) int { } // Set up a client. - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error initializing client: %s", err)) return 1 diff --git a/command/operator_autopilot_set_test.go b/command/operator_autopilot_set_test.go index 49bfa047dd..3c55070efe 100644 --- a/command/operator_autopilot_set_test.go +++ b/command/operator_autopilot_set_test.go @@ -5,9 +5,8 @@ import ( "testing" "time" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/mitchellh/cli" ) @@ -23,9 +22,9 @@ func TestOperator_Autopilot_Set(t *testing.T) { ui := cli.NewMockUi() c := OperatorAutopilotSetCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } args := []string{ diff --git a/command/operator_raft.go b/command/operator_raft.go index 72b3933ddc..421a6f5104 100644 --- a/command/operator_raft.go +++ b/command/operator_raft.go @@ -4,12 +4,10 @@ import ( "flag" "fmt" "strings" - - "github.com/hashicorp/consul/command/base" ) type OperatorRaftCommand struct { - base.Command + BaseCommand } func (c *OperatorRaftCommand) Help() string { @@ -44,7 +42,7 @@ func (c *OperatorRaftCommand) Run(args []string) int { // raft handles the raft subcommands. func (c *OperatorRaftCommand) raft(args []string) error { - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) // Parse verb arguments. var listPeers, removePeer bool @@ -63,9 +61,9 @@ func (c *OperatorRaftCommand) raft(args []string) error { // Leave these flags for backwards compatibility, but hide them // TODO: remove flags/behavior from this command in Consul 0.9 - c.Command.HideFlags("list-peers", "remove-peer", "address") + c.BaseCommand.HideFlags("list-peers", "remove-peer", "address") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { if err == flag.ErrHelp { return nil } @@ -73,14 +71,14 @@ func (c *OperatorRaftCommand) raft(args []string) error { } // Set up a client. - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { return fmt.Errorf("error connecting to Consul agent: %s", err) } // Dispatch based on the verb argument. if listPeers { - result, err := raftListPeers(client, c.Command.HTTPStale()) + result, err := raftListPeers(client, c.BaseCommand.HTTPStale()) if err != nil { c.UI.Error(fmt.Sprintf("Error getting peers: %v", err)) } diff --git a/command/operator_raft_list.go b/command/operator_raft_list.go index 17387d7dd2..7459f54e6e 100644 --- a/command/operator_raft_list.go +++ b/command/operator_raft_list.go @@ -6,13 +6,12 @@ import ( "strings" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" "github.com/hashicorp/serf/serf" "github.com/ryanuber/columnize" ) type OperatorRaftListCommand struct { - base.Command + BaseCommand } func (c *OperatorRaftListCommand) Help() string { @@ -21,7 +20,7 @@ Usage: consul operator raft list-peers [options] Displays the current Raft peer configuration. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -31,9 +30,9 @@ func (c *OperatorRaftListCommand) Synopsis() string { } func (c *OperatorRaftListCommand) Run(args []string) int { - c.Command.NewFlagSet(c) + c.BaseCommand.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { if err == flag.ErrHelp { return 0 } @@ -42,14 +41,14 @@ func (c *OperatorRaftListCommand) Run(args []string) int { } // Set up a client. - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error initializing client: %s", err)) return 1 } // Fetch the current configuration. - result, err := raftListPeers(client, c.Command.HTTPStale()) + result, err := raftListPeers(client, c.BaseCommand.HTTPStale()) if err != nil { c.UI.Error(fmt.Sprintf("Error getting peers: %v", err)) } diff --git a/command/operator_raft_list_test.go b/command/operator_raft_list_test.go index 8846fb1bc1..c3d6d7b828 100644 --- a/command/operator_raft_list_test.go +++ b/command/operator_raft_list_test.go @@ -5,8 +5,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) @@ -42,9 +41,9 @@ func TestOperator_Raft_ListPeers(t *testing.T) { { ui := cli.NewMockUi() c := OperatorRaftListCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } args := []string{"-http-addr=" + a.HTTPAddr()} diff --git a/command/operator_raft_remove.go b/command/operator_raft_remove.go index 4aa82e469a..d1dca8e213 100644 --- a/command/operator_raft_remove.go +++ b/command/operator_raft_remove.go @@ -6,11 +6,10 @@ import ( "strings" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" ) type OperatorRaftRemoveCommand struct { - base.Command + BaseCommand } func (c *OperatorRaftRemoveCommand) Help() string { @@ -26,7 +25,7 @@ quorum. If the server still shows in the output of the "consul members" command, it is preferable to clean up by simply running "consul force-leave" instead of this command. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -36,7 +35,7 @@ func (c *OperatorRaftRemoveCommand) Synopsis() string { } func (c *OperatorRaftRemoveCommand) Run(args []string) int { - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) var address, id string f.StringVar(&address, "address", "", @@ -44,7 +43,7 @@ func (c *OperatorRaftRemoveCommand) Run(args []string) int { f.StringVar(&id, "id", "", "The ID to remove from the Raft configuration.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { if err == flag.ErrHelp { return 0 } @@ -53,7 +52,7 @@ func (c *OperatorRaftRemoveCommand) Run(args []string) int { } // Set up a client. - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error initializing client: %s", err)) return 1 diff --git a/command/operator_raft_remove_test.go b/command/operator_raft_remove_test.go index f9629dcd0c..cc8a8d53da 100644 --- a/command/operator_raft_remove_test.go +++ b/command/operator_raft_remove_test.go @@ -4,8 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) @@ -40,9 +39,9 @@ func TestOperator_Raft_RemovePeer(t *testing.T) { { ui := cli.NewMockUi() c := OperatorRaftRemoveCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } args := []string{"-http-addr=" + a.HTTPAddr(), "-address=nope"} @@ -63,9 +62,9 @@ func TestOperator_Raft_RemovePeer(t *testing.T) { { ui := cli.NewMockUi() c := OperatorRaftRemoveCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } args := []string{"-http-addr=" + a.HTTPAddr(), "-id=nope"} diff --git a/command/operator_raft_test.go b/command/operator_raft_test.go index 3fe12d5e05..99eb7312b7 100644 --- a/command/operator_raft_test.go +++ b/command/operator_raft_test.go @@ -3,16 +3,15 @@ package command import ( "testing" - "github.com/hashicorp/consul/command/base" "github.com/mitchellh/cli" ) func testOperatorRaftCommand(t *testing.T) (*cli.MockUi, *OperatorRaftCommand) { ui := cli.NewMockUi() return ui, &OperatorRaftCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } } diff --git a/command/reload.go b/command/reload.go index f248e14ef9..1a37bee109 100644 --- a/command/reload.go +++ b/command/reload.go @@ -2,14 +2,13 @@ package command import ( "fmt" - "github.com/hashicorp/consul/command/base" "strings" ) // ReloadCommand is a Command implementation that instructs // the Consul agent to reload configurations type ReloadCommand struct { - base.Command + BaseCommand } func (c *ReloadCommand) Help() string { @@ -19,19 +18,19 @@ Usage: consul reload Causes the agent to reload configurations. This can be used instead of sending the SIGHUP signal to the agent. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } func (c *ReloadCommand) Run(args []string) int { - c.Command.NewFlagSet(c) + c.BaseCommand.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/reload_test.go b/command/reload_test.go index fdedb2fbe4..942244df25 100644 --- a/command/reload_test.go +++ b/command/reload_test.go @@ -4,8 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) @@ -27,9 +26,9 @@ func TestReloadCommandRun(t *testing.T) { ui := cli.NewMockUi() c := &ReloadCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, } args := []string{"-http-addr=" + a.HTTPAddr()} diff --git a/command/rtt.go b/command/rtt.go index 80b7309a3c..591677c67e 100644 --- a/command/rtt.go +++ b/command/rtt.go @@ -4,14 +4,13 @@ import ( "fmt" "strings" - "github.com/hashicorp/consul/command/base" "github.com/hashicorp/serf/coordinate" ) // RTTCommand is a Command implementation that allows users to query the // estimated round trip time between nodes using network coordinates. type RTTCommand struct { - base.Command + BaseCommand } func (c *RTTCommand) Help() string { @@ -34,7 +33,7 @@ Usage: consul rtt [options] node1 [node2] because they are maintained by independent Serf gossip areas, so they are not compatible. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -42,11 +41,11 @@ Usage: consul rtt [options] node1 [node2] func (c *RTTCommand) Run(args []string) int { var wan bool - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) f.BoolVar(&wan, "wan", false, "Use WAN coordinates instead of LAN coordinates.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -60,7 +59,7 @@ func (c *RTTCommand) Run(args []string) int { } // Create and test the HTTP client. - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/rtt_test.go b/command/rtt_test.go index c11cb13b70..13e1598902 100644 --- a/command/rtt_test.go +++ b/command/rtt_test.go @@ -6,9 +6,8 @@ import ( "testing" "time" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/serf/coordinate" "github.com/mitchellh/cli" @@ -17,9 +16,9 @@ import ( func testRTTCommand(t *testing.T) (*cli.MockUi, *RTTCommand) { ui := cli.NewMockUi() return ui, &RTTCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetClientHTTP, + Flags: FlagSetClientHTTP, }, } } diff --git a/command/snapshot_inspect.go b/command/snapshot_inspect.go index 7a4f75dbe5..4ffb99650a 100644 --- a/command/snapshot_inspect.go +++ b/command/snapshot_inspect.go @@ -7,14 +7,13 @@ import ( "strings" "text/tabwriter" - "github.com/hashicorp/consul/command/base" "github.com/hashicorp/consul/snapshot" ) // SnapshotInspectCommand is a Command implementation that is used to display // metadata about a snapshot file type SnapshotInspectCommand struct { - base.Command + BaseCommand } func (c *SnapshotInspectCommand) Help() string { @@ -34,9 +33,9 @@ Usage: consul snapshot inspect [options] FILE } func (c *SnapshotInspectCommand) Run(args []string) int { - flagSet := c.Command.NewFlagSet(c) + flagSet := c.BaseCommand.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } diff --git a/command/snapshot_inspect_test.go b/command/snapshot_inspect_test.go index 852baf7a97..1e501ec5ec 100644 --- a/command/snapshot_inspect_test.go +++ b/command/snapshot_inspect_test.go @@ -7,8 +7,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/testutil" "github.com/mitchellh/cli" ) @@ -16,9 +15,9 @@ import ( func testSnapshotInspectCommand(t *testing.T) (*cli.MockUi, *SnapshotInspectCommand) { ui := cli.NewMockUi() return ui, &SnapshotInspectCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetNone, + Flags: FlagSetNone, }, } } diff --git a/command/snapshot_restore.go b/command/snapshot_restore.go index ae1e413f76..c3ba6947a9 100644 --- a/command/snapshot_restore.go +++ b/command/snapshot_restore.go @@ -4,14 +4,12 @@ import ( "fmt" "os" "strings" - - "github.com/hashicorp/consul/command/base" ) // SnapshotRestoreCommand is a Command implementation that is used to restore // the state of the Consul servers for disaster recovery. type SnapshotRestoreCommand struct { - base.Command + BaseCommand } func (c *SnapshotRestoreCommand) Help() string { @@ -36,15 +34,15 @@ Usage: consul snapshot restore [options] FILE For a full list of options and examples, please see the Consul documentation. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } func (c *SnapshotRestoreCommand) Run(args []string) int { - flagSet := c.Command.NewFlagSet(c) + flagSet := c.BaseCommand.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -63,7 +61,7 @@ func (c *SnapshotRestoreCommand) Run(args []string) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 diff --git a/command/snapshot_restore_test.go b/command/snapshot_restore_test.go index 23af9d231c..d52dc9f893 100644 --- a/command/snapshot_restore_test.go +++ b/command/snapshot_restore_test.go @@ -7,8 +7,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/testutil" "github.com/mitchellh/cli" ) @@ -16,9 +15,9 @@ import ( func testSnapshotRestoreCommand(t *testing.T) (*cli.MockUi, *SnapshotRestoreCommand) { ui := cli.NewMockUi() return ui, &SnapshotRestoreCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } } diff --git a/command/snapshot_save.go b/command/snapshot_save.go index 8f724919fe..74c4171f46 100644 --- a/command/snapshot_save.go +++ b/command/snapshot_save.go @@ -7,14 +7,13 @@ import ( "strings" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/command/base" "github.com/hashicorp/consul/snapshot" ) // SnapshotSaveCommand is a Command implementation that is used to save the // state of the Consul servers for disaster recovery. type SnapshotSaveCommand struct { - base.Command + BaseCommand } func (c *SnapshotSaveCommand) Help() string { @@ -39,15 +38,15 @@ Usage: consul snapshot save [options] FILE For a full list of options and examples, please see the Consul documentation. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } func (c *SnapshotSaveCommand) Run(args []string) int { - flagSet := c.Command.NewFlagSet(c) + flagSet := c.BaseCommand.NewFlagSet(c) - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -66,7 +65,7 @@ func (c *SnapshotSaveCommand) Run(args []string) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 @@ -74,7 +73,7 @@ func (c *SnapshotSaveCommand) Run(args []string) int { // Take the snapshot. snap, qm, err := client.Snapshot().Save(&api.QueryOptions{ - AllowStale: c.Command.HTTPStale(), + AllowStale: c.BaseCommand.HTTPStale(), }) if err != nil { c.UI.Error(fmt.Sprintf("Error saving snapshot: %s", err)) diff --git a/command/snapshot_save_test.go b/command/snapshot_save_test.go index b2001e134a..40d02ee4e8 100644 --- a/command/snapshot_save_test.go +++ b/command/snapshot_save_test.go @@ -6,8 +6,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/testutil" "github.com/mitchellh/cli" ) @@ -15,9 +14,9 @@ import ( func testSnapshotSaveCommand(t *testing.T) (*cli.MockUi, *SnapshotSaveCommand) { ui := cli.NewMockUi() return ui, &SnapshotSaveCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } } diff --git a/command/validate.go b/command/validate.go index 9b7f76328b..87e858c42d 100644 --- a/command/validate.go +++ b/command/validate.go @@ -4,14 +4,13 @@ import ( "fmt" "strings" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" ) // ValidateCommand is a Command implementation that is used to // verify config files type ValidateCommand struct { - base.Command + BaseCommand } func (c *ValidateCommand) Help() string { @@ -26,7 +25,7 @@ Usage: consul validate [options] FILE_OR_DIRECTORY... Returns 0 if the configuration is valid, or 1 if there are problems. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -35,17 +34,17 @@ func (c *ValidateCommand) Run(args []string) int { var configFiles []string var quiet bool - f := c.Command.NewFlagSet(c) - f.Var((*agent.AppendSliceValue)(&configFiles), "config-file", + f := c.BaseCommand.NewFlagSet(c) + f.Var((*AppendSliceValue)(&configFiles), "config-file", "Path to a JSON file to read configuration from. This can be specified multiple times.") - f.Var((*agent.AppendSliceValue)(&configFiles), "config-dir", + f.Var((*AppendSliceValue)(&configFiles), "config-dir", "Path to a directory to read configuration files from. This will read every file ending in "+ ".json as configuration in this directory in alphabetical order.") f.BoolVar(&quiet, "quiet", false, "When given, a successful run will produce no output.") - c.Command.HideFlags("config-file", "config-dir") + c.BaseCommand.HideFlags("config-file", "config-dir") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } diff --git a/command/validate_test.go b/command/validate_test.go index 7d1511c340..8d428c91eb 100644 --- a/command/validate_test.go +++ b/command/validate_test.go @@ -6,7 +6,6 @@ import ( "path/filepath" "testing" - "github.com/hashicorp/consul/command/base" "github.com/hashicorp/consul/testutil" "github.com/mitchellh/cli" ) @@ -14,9 +13,9 @@ import ( func testValidateCommand(t *testing.T) (*cli.MockUi, *ValidateCommand) { ui := cli.NewMockUi() return ui, &ValidateCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetNone, + Flags: FlagSetNone, }, } } diff --git a/command/version.go b/command/version.go index f75e328d33..581cb5d431 100644 --- a/command/version.go +++ b/command/version.go @@ -3,8 +3,8 @@ package command import ( "fmt" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/consul" + "github.com/hashicorp/consul/agent" + "github.com/hashicorp/consul/agent/consul" "github.com/mitchellh/cli" ) diff --git a/command/watch.go b/command/watch.go index fb38d354f3..20c852a7ec 100644 --- a/command/watch.go +++ b/command/watch.go @@ -8,15 +8,14 @@ import ( "strconv" "strings" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/watch" ) // WatchCommand is a Command implementation that is used to setup // a "watch" which uses a sub-process type WatchCommand struct { - base.Command + BaseCommand ShutdownCh <-chan struct{} } @@ -31,7 +30,7 @@ Usage: consul watch [options] [child...] Providing the watch type is required, and other parameters may be required or supported depending on the watch type. -` + c.Command.Help() +` + c.BaseCommand.Help() return strings.TrimSpace(helpText) } @@ -39,7 +38,7 @@ Usage: consul watch [options] [child...] func (c *WatchCommand) Run(args []string) int { var watchType, key, prefix, service, tag, passingOnly, state, name string - f := c.Command.NewFlagSet(c) + f := c.BaseCommand.NewFlagSet(c) f.StringVar(&watchType, "type", "", "Specifies the watch type. One of key, keyprefix, services, nodes, "+ "service, checks, or event.") @@ -60,7 +59,7 @@ func (c *WatchCommand) Run(args []string) int { f.StringVar(&name, "name", "", "Specifies an event name to watch. Only for 'event' type.") - if err := c.Command.Parse(args); err != nil { + if err := c.BaseCommand.Parse(args); err != nil { return 1 } @@ -80,11 +79,11 @@ func (c *WatchCommand) Run(args []string) int { if watchType != "" { params["type"] = watchType } - if c.Command.HTTPDatacenter() != "" { - params["datacenter"] = c.Command.HTTPDatacenter() + if c.BaseCommand.HTTPDatacenter() != "" { + params["datacenter"] = c.BaseCommand.HTTPDatacenter() } - if c.Command.HTTPToken() != "" { - params["token"] = c.Command.HTTPToken() + if c.BaseCommand.HTTPToken() != "" { + params["token"] = c.BaseCommand.HTTPToken() } if key != "" { params["key"] = key @@ -98,8 +97,8 @@ func (c *WatchCommand) Run(args []string) int { if tag != "" { params["tag"] = tag } - if c.Command.HTTPStale() { - params["stale"] = c.Command.HTTPStale() + if c.BaseCommand.HTTPStale() { + params["stale"] = c.BaseCommand.HTTPStale() } if state != "" { params["state"] = state @@ -124,7 +123,7 @@ func (c *WatchCommand) Run(args []string) int { } // Create and test the HTTP client - client, err := c.Command.HTTPClient() + client, err := c.BaseCommand.HTTPClient() if err != nil { c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1 @@ -194,7 +193,7 @@ func (c *WatchCommand) Run(args []string) int { }() // Run the watch - if err := wp.Run(c.Command.HTTPAddr()); err != nil { + if err := wp.Run(c.BaseCommand.HTTPAddr()); err != nil { c.UI.Error(fmt.Sprintf("Error querying Consul agent: %s", err)) return 1 } diff --git a/command/watch_test.go b/command/watch_test.go index abf8dd6282..4fe32c9aa4 100644 --- a/command/watch_test.go +++ b/command/watch_test.go @@ -4,8 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/command/agent" - "github.com/hashicorp/consul/command/base" + "github.com/hashicorp/consul/agent" "github.com/mitchellh/cli" ) @@ -21,9 +20,9 @@ func TestWatchCommandRun(t *testing.T) { ui := cli.NewMockUi() c := &WatchCommand{ - Command: base.Command{ + BaseCommand: BaseCommand{ UI: ui, - Flags: base.FlagSetHTTP, + Flags: FlagSetHTTP, }, } args := []string{"-http-addr=" + a.HTTPAddr(), "-type=nodes"} diff --git a/main.go b/main.go index 831c007522..3839455dcf 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "log" "os" + "github.com/hashicorp/consul/command" "github.com/hashicorp/consul/lib" "github.com/mitchellh/cli" ) @@ -21,7 +22,7 @@ func main() { func realMain() int { log.SetOutput(ioutil.Discard) - // Get the command line args. We shortcut "--version" and "-v" to + // Get the c line args. We shortcut "--version" and "-v" to // just show the version. args := os.Args[1:] for _, arg := range args { @@ -37,17 +38,17 @@ func realMain() int { } } - // Filter out the configtest command from the help display + // Filter out the configtest c from the help display var included []string - for command := range Commands { - if command != "configtest" { - included = append(included, command) + for c := range command.Commands { + if c != "configtest" { + included = append(included, c) } } cli := &cli.CLI{ Args: args, - Commands: Commands, + Commands: command.Commands, HelpFunc: cli.FilteredHelpFunc(included, cli.BasicHelpFunc("consul")), } diff --git a/testrpc/wait.go b/testrpc/wait.go index ac6fe15a87..1a5cf8c841 100644 --- a/testrpc/wait.go +++ b/testrpc/wait.go @@ -3,7 +3,7 @@ package testrpc import ( "testing" - "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/testutil/retry" )