acc843f04d
This PR is based on the previous work by @snuggie12 in PR #6825. It adds the command consul intention list to list all available intentions. The list functionality for intentions seems a bit overdue as it's just very handy. The web UI cannot list intentions outside of the default namespace, and using the API is sometimes not the friendliest option. ;) I cherry picked snuggie12's commits who did most of the heavy lifting (thanks again @snuggie12 for your great work!). The changes in the original commit mostly still worked on the current HEAD. On top of that I added support for namespaces and fixed the docs as they are managed differently today. Also the requested changes related to the "Connect" references in the original PRs have been addressed. Fixes #5652 Co-authored-by: Matt Hoey <mhoey05@jcu.edu>
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package intention
|
|
|
|
import (
|
|
"github.com/hashicorp/consul/command/flags"
|
|
"github.com/mitchellh/cli"
|
|
)
|
|
|
|
func New() *cmd {
|
|
return &cmd{}
|
|
}
|
|
|
|
type cmd struct{}
|
|
|
|
func (c *cmd) Run(args []string) int {
|
|
return cli.RunResultHelp
|
|
}
|
|
|
|
func (c *cmd) Synopsis() string {
|
|
return synopsis
|
|
}
|
|
|
|
func (c *cmd) Help() string {
|
|
return flags.Usage(help, nil)
|
|
}
|
|
|
|
const synopsis = "Interact with Connect service intentions"
|
|
const help = `
|
|
Usage: consul intention <subcommand> [options] [args]
|
|
|
|
This command has subcommands for interacting with intentions. Intentions
|
|
are permissions describing which services are allowed to communicate via
|
|
Connect. Here are some simple examples, and more detailed examples are
|
|
available in the subcommands or the documentation.
|
|
|
|
Create an intention to allow "web" to talk to "db":
|
|
|
|
$ consul intention create web db
|
|
|
|
Test whether a "web" is allowed to connect to "db":
|
|
|
|
$ consul intention check web db
|
|
|
|
List all intentions:
|
|
|
|
$ consul intention list
|
|
|
|
Find all intentions for communicating to the "db" service:
|
|
|
|
$ consul intention match db
|
|
|
|
For more examples, ask for subcommand help or view the documentation.
|
|
`
|