From faa06040e4414734f428c1873a0d9161f43da70a Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 5 Jul 2021 15:17:54 -0400 Subject: [PATCH] contrib: Add CLI docs --- contributing/README.md | 2 ++ contributing/cli/README.md | 36 ++++++++++++++++++++++++++++++ contributing/http-api/README.md | 3 +++ contributing/overview.mmd | 6 +++++ contributing/overview.svg | 2 +- contributing/persistence/README.md | 7 ++++++ 6 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 contributing/cli/README.md create mode 100644 contributing/http-api/README.md diff --git a/contributing/README.md b/contributing/README.md index 6b8048600..e5e96f0b7 100644 --- a/contributing/README.md +++ b/contributing/README.md @@ -21,6 +21,8 @@ found in the public [user documentation]. ## Contents 1. [Overview](./INTERNALS.md) +1. [Command-Line Interface (CLI)](./cli) +1. [HTTP API](./http-api) 1. [Agent Configuration](./config) 1. [RPC](./rpc) 1. [Cluster Persistence](./persistence) diff --git a/contributing/cli/README.md b/contributing/cli/README.md new file mode 100644 index 000000000..aaa1a8e55 --- /dev/null +++ b/contributing/cli/README.md @@ -0,0 +1,36 @@ +# Command-Line Interface (CLI) + +This section is a work in progress. + +The `consul` binary provides a CLI for interacting with the [HTTP API]. Some commands may +also exec other processes or generate data used by Consul (ex: tls certificates). The +`agent` command is responsible for starting the Consul agent. + +The [cli reference] in Consul user documentation has a full reference to all available +commands. + +[HTTP API]: ../http-api +[cli reference]: https://www.consul.io/commands + +## Code + +The CLI entrypoint is [main.go] and the majority of the source for the CLI is under the +[command] directory. Each subcommand is a separate package under [command]. The CLI uses +[github.com/mitchellh/cli] as a framework, and uses the [flag] package from the stdlib for +command line flags. + + +[command]: https://github.com/hashicorp/consul/tree/main/command +[main.go]: https://github.com/hashicorp/consul/blob/main/main.go +[flag]: https://pkg.go.dev/flag +[github.com/mitchellh/cli]: https://github.com/mitchellh/cli + +## Important notes + +The [cli.Ui] wraps an `io.Writer` for both stdout and stderr. At the time of writing both +`Info` and `Output` go to stdout. Writing `Info` to stdout has been a source of a couple +bugs. To prevent these bugs in the future it is recommended that `Info` should no longer +be used. Instead, send all information messages to stderr by using `Warn`. + + +[cli.Ui]: https://pkg.go.dev/github.com/mitchellh/cli#Ui diff --git a/contributing/http-api/README.md b/contributing/http-api/README.md new file mode 100644 index 000000000..ab1575473 --- /dev/null +++ b/contributing/http-api/README.md @@ -0,0 +1,3 @@ +# HTTP API + +Work in progress. diff --git a/contributing/overview.mmd b/contributing/overview.mmd index ae210a919..5da52614f 100644 --- a/contributing/overview.mmd +++ b/contributing/overview.mmd @@ -11,6 +11,12 @@ graph TD ClientAgent[Client Agent] RPC ClusterPersistence[Cluster Persistence] + CLI + HTTPAPI[HTTP API] + + CLI --> HTTPAPI + HTTPAPI --> ClientAgent + HTTPAPI --> ACL AgentConfiguration --> ClientAgent ClientAgent --> RPC diff --git a/contributing/overview.svg b/contributing/overview.svg index 44d77c94e..94c7c9822 100644 --- a/contributing/overview.svg +++ b/contributing/overview.svg @@ -1 +1 @@ -
Sercice Mesh
Service Discovery
Cluster Membership
Key/Value Store
Multi-Cluster Federation
ACL
Agent Configuration
Client Agent
RPC
Cluster Persistence
\ No newline at end of file +
Sercice Mesh
Service Discovery
Cluster Membership
Key/Value Store
Multi-Cluster Federation
ACL
Agent Configuration
Client Agent
RPC
Cluster Persistence
CLI
HTTP API
\ No newline at end of file diff --git a/contributing/persistence/README.md b/contributing/persistence/README.md index 12e1c0e7f..edcc0ecd6 100644 --- a/contributing/persistence/README.md +++ b/contributing/persistence/README.md @@ -6,3 +6,10 @@ - boltdb - https://github.com/boltdb/bolt (https://github.com/etcd-io/bbolt) - snapshot and restore + +## Additional documentation + +The following links provide more detail about about cluster persistence. + +* [Consul Architecture Guide](https://www.consul.io/docs/architecture) +