github.com/djenriquez/nomad-1@v0.8.1/command/quota.go (about) 1 package command 2 3 import ( 4 "strings" 5 6 "github.com/hashicorp/nomad/api/contexts" 7 "github.com/mitchellh/cli" 8 "github.com/posener/complete" 9 ) 10 11 type QuotaCommand struct { 12 Meta 13 } 14 15 func (f *QuotaCommand) Help() string { 16 helpText := ` 17 Usage: nomad quota <subcommand> [options] [args] 18 19 This command groups subcommands for interacting with resource quotas. Resource 20 quotas allow operators to restrict the aggregate resource usage of namespaces. 21 Users can inspect existing quota specifications, create new quotas, delete and 22 list existing quotas, and more. For a full guide on resource quotas see: 23 https://www.nomadproject.io/guides/quotas.html 24 25 Examine a quota's status: 26 27 $ nomad quota status <name> 28 29 List existing quotas: 30 31 $ nomad quota list 32 33 Create a new quota specification: 34 35 $ nomad quota apply <path> 36 37 Please see the individual subcommand help for detailed usage information. 38 ` 39 40 return strings.TrimSpace(helpText) 41 } 42 43 func (f *QuotaCommand) Synopsis() string { 44 return "Interact with quotas" 45 } 46 47 func (f *QuotaCommand) Run(args []string) int { 48 return cli.RunResultHelp 49 } 50 51 // QuotaPredictor returns a quota predictor 52 func QuotaPredictor(factory ApiClientFactory) complete.Predictor { 53 return complete.PredictFunc(func(a complete.Args) []string { 54 client, err := factory() 55 if err != nil { 56 return nil 57 } 58 59 resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Quotas, nil) 60 if err != nil { 61 return []string{} 62 } 63 return resp.Matches[contexts.Quotas] 64 }) 65 }