diff --git a/command/acl.go b/command/acl.go index 3a6461a22..4cc45a18c 100644 --- a/command/acl.go +++ b/command/acl.go @@ -12,11 +12,17 @@ type ACLCommand struct { func (f *ACLCommand) Help() string { helpText := ` -Usage: nomad acl [options] +Usage: nomad acl [options] [args] - Interact with ACL policies and tokens. + This command groups subcommands for interacting with ACL policies and tokens. + Users can bootstrap Nomad's ACL system, create policies that restrict access, + and generate tokens from those policies. - Run nomad acl with no arguments for help on that subcommand. + Bootstrap ACLs: + + $ nomad acl bootstrap + + Please see the individual subcommand help for detailed usage information. ` return strings.TrimSpace(helpText) } diff --git a/command/acl_policy.go b/command/acl_policy.go index 43eaf26dc..28e9e1be0 100644 --- a/command/acl_policy.go +++ b/command/acl_policy.go @@ -1,13 +1,39 @@ package command -import "github.com/mitchellh/cli" +import ( + "strings" + + "github.com/mitchellh/cli" +) type ACLPolicyCommand struct { Meta } func (f *ACLPolicyCommand) Help() string { - return "This command is accessed by using one of the subcommands below." + helpText := ` +Usage: nomad acl policy [options] [args] + + This command groups subcommands for interacting with ACL policies. Nomad's ACL + system can be used to control access to data and APIs. ACL policies allow a + set of capabilities or actions to be granted or whitelisted. For a full guide + see: https://www.nomadproject.io/guides/acl.html + + Create an ACL policy: + + $ nomad acl policy apply + + List ACL policies: + + $ nomad acl policy list + + Inspect an ACL policy: + + $ nomad acl policy info + + Please see the individual subcommand help for detailed usage information. +` + return strings.TrimSpace(helpText) } func (f *ACLPolicyCommand) Synopsis() string { diff --git a/command/acl_token.go b/command/acl_token.go index d11f06b6a..8f1faa503 100644 --- a/command/acl_token.go +++ b/command/acl_token.go @@ -1,13 +1,39 @@ package command -import "github.com/mitchellh/cli" +import ( + "strings" + + "github.com/mitchellh/cli" +) type ACLTokenCommand struct { Meta } func (f *ACLTokenCommand) Help() string { - return "This command is accessed by using one of the subcommands below." + helpText := ` +Usage: nomad acl token [options] [args] + + This command groups subcommands for interacting with ACL tokens. Nomad's ACL + system can be used to control access to data and APIs. ACL tokens are + associated with one or more ACL policies which grant specific capabilities. + For a full guide see: https://www.nomadproject.io/guides/acl.html + + Create an ACL token: + + $ nomad acl token create -name "my-token" -policy foo -policy bar + + Lookup a token and display its associated policies: + + $ nomad acl policy info + + Revoke an ACL token: + + $ nomad acl policy delete + + Please see the individual subcommand help for detailed usage information. +` + return strings.TrimSpace(helpText) } func (f *ACLTokenCommand) Synopsis() string { diff --git a/command/alloc.go b/command/alloc.go index f2729a42f..04f232b3f 100644 --- a/command/alloc.go +++ b/command/alloc.go @@ -1,13 +1,34 @@ package command -import "github.com/mitchellh/cli" +import ( + "strings" + + "github.com/mitchellh/cli" +) type AllocCommand struct { Meta } func (f *AllocCommand) Help() string { - return "This command is accessed by using one of the subcommands below." + helpText := ` +Usage: nomad alloc [options] [args] + + This command groups subcommands for interacting with allocations. Users can + inspect the status, examine the filesystem or logs of an allocation. + + Examine an allocations status: + + $ nomad alloc status + + Stream a task's logs: + + $ nomad alloc logs -f + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) } func (f *AllocCommand) Synopsis() string { diff --git a/command/deployment.go b/command/deployment.go index 8c4328a53..d30bfa4a3 100644 --- a/command/deployment.go +++ b/command/deployment.go @@ -1,13 +1,43 @@ package command -import "github.com/mitchellh/cli" +import ( + "strings" + + "github.com/mitchellh/cli" +) type DeploymentCommand struct { Meta } func (f *DeploymentCommand) Help() string { - return "This command is accessed by using one of the subcommands below." + helpText := ` +Usage: nomad deployment [options] [args] + + This command groups subcommands for interacting with deployments. Deployments + are used to manage a transistion between two versions of a Nomad job. Users + can inspect an ongoing deployment, promote canary allocations, force fail + deployments, and more. + + Examine a deployments status: + + $ nomad deployment status + + Promote the canaries to allow the remaining allocations to be updated in a + rolling deployment fashion: + + $ nomad deployment promote + + Mark a deployment as failed. This will stop new allocations from being placed + and if the job's upgrade stanza specifies auto_revert, causes the job to + revert back to the last stable version of the job: + + $ nomad deployment fail + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) } func (f *DeploymentCommand) Synopsis() string { diff --git a/command/eval.go b/command/eval.go index 70959d181..a1031634f 100644 --- a/command/eval.go +++ b/command/eval.go @@ -1,13 +1,32 @@ package command -import "github.com/mitchellh/cli" +import ( + "strings" + + "github.com/mitchellh/cli" +) type EvalCommand struct { Meta } func (f *EvalCommand) Help() string { - return "This command is accessed by using one of the subcommands below." + helpText := ` +Usage: nomad eval [options] [args] + + This command groups subcommands for interacting with evaluations. Evaluations + are used to trigger a scheduling event. As such, evaluations are an internal + detail but can be useful for debugging placement failures when the cluster + does not have the resources to run a given job. + + Examine an evaluations status: + + $ nomad eval status + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) } func (f *EvalCommand) Synopsis() string { diff --git a/command/job.go b/command/job.go index 35477146f..36d0e1ce2 100644 --- a/command/job.go +++ b/command/job.go @@ -1,13 +1,41 @@ package command -import "github.com/mitchellh/cli" +import ( + "strings" + + "github.com/mitchellh/cli" +) type JobCommand struct { Meta } func (f *JobCommand) Help() string { - return "This command is accessed by using one of the subcommands below." + helpText := ` +Usage: nomad job [options] [args] + + This command groups subcommands for interacting with jobs. + + Run a new job or update an existing job: + + $ nomad job run + + Plan the run of a job to determine what changes would occur: + + $ nomad job plan + + Stop a running job: + + $ nomad job stop + + Examine the status of a running job: + + $ nomad job status + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) } func (f *JobCommand) Synopsis() string { diff --git a/command/namespace.go b/command/namespace.go index 5533614a4..d43deec84 100644 --- a/command/namespace.go +++ b/command/namespace.go @@ -1,6 +1,8 @@ package command import ( + "strings" + "github.com/hashicorp/nomad/api/contexts" "github.com/mitchellh/cli" "github.com/posener/complete" @@ -11,7 +13,30 @@ type NamespaceCommand struct { } func (f *NamespaceCommand) Help() string { - return "This command is accessed by using one of the subcommands below." + helpText := ` +Usage: nomad namespace [options] [args] + + This command groups subcommands for interacting with namespaces. Namespaces + allow jobs and their associated objects to be segmented from each other and + other users of the cluster. For a full guide on namespaces see: + https://www.nomadproject.io/guides/namespaces.html + + Create or update a namespace: + + $ nomad namespace apply -description "My new namespace" + + List namespaces: + + $ nomad namespace list + + View the status of a namespace: + + $ nomad namespace status + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) } func (f *NamespaceCommand) Synopsis() string { diff --git a/command/node.go b/command/node.go index 36436d9b7..0479d0b20 100644 --- a/command/node.go +++ b/command/node.go @@ -1,13 +1,41 @@ package command -import "github.com/mitchellh/cli" +import ( + "strings" + + "github.com/mitchellh/cli" +) type NodeCommand struct { Meta } func (f *NodeCommand) Help() string { - return "This command is accessed by using one of the subcommands below." + helpText := ` +Usage: nomad nomad [options] [args] + + This command groups subcommands for interacting with nodes. Nodes in Nomad are + agent's that can run submitted workloads. This command can be used to examine + nodes and operate on nodes, such as draining workloads off of them. + + Examine the status of a node: + + $ nomad node status + + Mark a node as ineligible for running workloads. This is useful when the node + is expected to be removed or upgraded so new allocations aren't placed on it: + + $ nomad node eligibility -disabled + + Mark a node to be drained, allowing batch jobs four hours to finished before + forcing them off the node: + + $ nomad node drain -enable -deadline 4h + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) } func (f *NodeCommand) Synopsis() string { diff --git a/command/operator.go b/command/operator.go index db5ed3574..850154ba6 100644 --- a/command/operator.go +++ b/command/operator.go @@ -18,7 +18,7 @@ Usage: nomad operator [options] the Raft subsystem. NOTE: Use this command with extreme caution, as improper use could lead to a Nomad outage and even loss of data. - Run nomad operator with no arguments for help on that subcommand. + Please see the individual subcommand help for detailed usage information. ` return strings.TrimSpace(helpText) } diff --git a/command/operator_autopilot.go b/command/operator_autopilot.go index d4c4cdd5b..49fef0bc4 100644 --- a/command/operator_autopilot.go +++ b/command/operator_autopilot.go @@ -22,8 +22,49 @@ func (c *OperatorAutopilotCommand) Help() string { helpText := ` Usage: nomad operator autopilot [options] - The Autopilot operator command is used to interact with Nomad's Autopilot - subsystem. The command can be used to view or modify the current configuration. -` + This command groups subcommands for interacting with Nomad's Autopilot + subsystem. Autopilot provides automatic, operator-friendly management of Nomad + servers. The command can be used to view or modify the current Autopilot + configuration. + + Get the current Autopilot configuration: + + $ nomad operator autopilot get-config + + Set a new Autopilot configuration, enabling automatic dead server cleanup: + + $ nomad operator autopilot set-config -cleanup-dead-servers=true + + Please see the individual subcommand help for detailed usage information. + ` return strings.TrimSpace(helpText) + /* + helpText := ` + Usage: nomad deployment [options] [args] + + This command groups subcommands for interacting with deployments. Deployments + are used to manage a transistion between two versions of a Nomad job. Users + can inspect an ongoing deployment, promote canary allocations, force fail + deployments, and more. + + Examine a deployments status: + + $ nomad deployment status + + Promote the canaries to allow the remaining allocations to be updated in a + rolling deployment fashion: + + $ nomad deployment promote + + Mark a deployment as failed. This will stop new allocations from being placed + and if the job's upgrade stanza specifies auto_revert, causes the job to + revert back to the last stable version of the job: + + $ nomad deployment fail + + Please see the individual subcommand help for detailed usage information. + ` + + return strings.TrimSpace(helpText) + */ } diff --git a/command/operator_raft.go b/command/operator_raft.go index 16d89e77f..5d6df4ead 100644 --- a/command/operator_raft.go +++ b/command/operator_raft.go @@ -14,9 +14,19 @@ func (c *OperatorRaftCommand) Help() string { helpText := ` Usage: nomad operator raft [options] - The Raft operator command is used to interact with Nomad's Raft subsystem. The - command can be used to verify Raft peers or in rare cases to recover quorum by - removing invalid peers. + This command groups subcommands for interacting with Nomad's Raft subsystem. + The command can be used to verify Raft peers or in rare cases to recover + quorum by removing invalid peers. + + List Raft peers: + + $ nomad operator raft list-peers + + Remove a Raft peer: + + $ nomad operator raft remove-peer -peer-address "IP:Port" + + Please see the individual subcommand help for detailed usage information. ` return strings.TrimSpace(helpText) } diff --git a/command/quota.go b/command/quota.go index 46959d5a4..62d357081 100644 --- a/command/quota.go +++ b/command/quota.go @@ -1,6 +1,8 @@ package command import ( + "strings" + "github.com/hashicorp/nomad/api/contexts" "github.com/mitchellh/cli" "github.com/posener/complete" @@ -11,7 +13,31 @@ type QuotaCommand struct { } func (f *QuotaCommand) Help() string { - return "This command is accessed by using one of the subcommands below." + helpText := ` +Usage: nomad quota [options] [args] + + This command groups subcommands for interacting with resource quotas. Resource + quotas allow operators to restrict the aggregate resource usage of namespaces. + Users can inspect existing quota specifications, create new quotas, delete and + list existing quotas, and more. For a full guide on resource quotas see: + https://www.nomadproject.io/guides/quotas.html + + Examine a quota's status: + + $ nomad quota status + + List existing quotas: + + $ nomad quota list + + Create a new quota specification: + + $ nomad quota apply + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) } func (f *QuotaCommand) Synopsis() string { diff --git a/command/sentinel.go b/command/sentinel.go index fe8ffba60..4e30f98bf 100644 --- a/command/sentinel.go +++ b/command/sentinel.go @@ -1,13 +1,44 @@ package command -import "github.com/mitchellh/cli" +import ( + "strings" + + "github.com/mitchellh/cli" +) type SentinelCommand struct { Meta } func (f *SentinelCommand) Help() string { - return "This command is accessed by using one of the subcommands below." + helpText := ` +Usage: nomad sentinel [options] [args] + + This command groups subcommands for interacting with Sentinel policies. + Sentinel policies allow operators to express fine-grained policies as code and + have their policies automatically enforced. This allows operators to define a + "sandbox" and restrict actions to only those compliant with policy. The + Sentinel integration builds on the ACL System. Users can read existing + Sentinel policies, create new policies, delete and list existing policies, and + more. For a full guide on Sentinel policies see: + https://www.nomadproject.io/guides/sentinel-policy.html + + Read an existing policy: + + $ nomad sentinel read + + List existing policies: + + $ nomad sentinel list + + Create a new Sentinel policy: + + $ nomad sentinel apply + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) } func (f *SentinelCommand) Synopsis() string { diff --git a/command/server.go b/command/server.go index 7735fcc87..f675869cb 100644 --- a/command/server.go +++ b/command/server.go @@ -1,13 +1,38 @@ package command -import "github.com/mitchellh/cli" +import ( + "strings" + + "github.com/mitchellh/cli" +) type ServerCommand struct { Meta } func (f *ServerCommand) Help() string { - return "This command is accessed by using one of the subcommands below." + helpText := ` +Usage: nomad server [options] [args] + + This command groups subcommands for interacting with Nomad servers. Users can + list Servers, join a server to the cluster, and force leave a server. + + List Nomad servers: + + $ nomad server members + + Join a new server to another: + + $ nomad server join "IP:Port" + + Force a server to leave: + + $ nomad server force-leave + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) } func (f *ServerCommand) Synopsis() string {