github.com/blixtra/nomad@v0.7.2-0.20171221000451-da9a1d7bb050/command/quota.go (about)

     1  package command
     2  
     3  import (
     4  	"github.com/hashicorp/nomad/api/contexts"
     5  	"github.com/mitchellh/cli"
     6  	"github.com/posener/complete"
     7  )
     8  
     9  type QuotaCommand struct {
    10  	Meta
    11  }
    12  
    13  func (f *QuotaCommand) Help() string {
    14  	return "This command is accessed by using one of the subcommands below."
    15  }
    16  
    17  func (f *QuotaCommand) Synopsis() string {
    18  	return "Interact with quotas"
    19  }
    20  
    21  func (f *QuotaCommand) Run(args []string) int {
    22  	return cli.RunResultHelp
    23  }
    24  
    25  // QuotaPredictor returns a quota predictor
    26  func QuotaPredictor(factory ApiClientFactory) complete.Predictor {
    27  	return complete.PredictFunc(func(a complete.Args) []string {
    28  		client, err := factory()
    29  		if err != nil {
    30  			return nil
    31  		}
    32  
    33  		resp, _, err := client.Search().PrefixSearch(a.Last, contexts.Quotas, nil)
    34  		if err != nil {
    35  			return []string{}
    36  		}
    37  		return resp.Matches[contexts.Quotas]
    38  	})
    39  }