github.com/aminovpavel/nomad@v0.11.8/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) Name() string { return "quota" } 48 49 func (f *QuotaCommand) Run(args []string) int { 50 return cli.RunResultHelp 51 } 52 53 // QuotaPredictor returns a quota predictor 54 func QuotaPredictor(factory ApiClientFactory) complete.Predictor { 55 return complete.PredictFunc(func(a complete.Args) []string { 56 client, err := factory() 57 if err != nil { 58 return nil 59 } 60 61 resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Quotas, nil) 62 if err != nil { 63 return []string{} 64 } 65 return resp.Matches[contexts.Quotas] 66 }) 67 }