update fetch function

This commit is contained in:
nhatle 2022-07-28 16:13:28 -07:00
parent 2ca005eea8
commit 9ef09cc36a

View file

@ -108,10 +108,10 @@ func init() {
fetchCmd.AddCommand(fetchQuotaCmd) fetchCmd.AddCommand(fetchQuotaCmd)
// fetch capacity // fetch capacity
fetchCmd.AddCommand(fetchCapacityCmd) fetchCmd.AddCommand(fetchAvailCapacityCmd)
// Hijack help function to hide unnecessary global flags // Hijack help function to hide unnecessary global flags
fetchCapacityCmd.SetHelpFunc(func(cmd *cobra.Command, s []string) { fetchAvailCapacityCmd.SetHelpFunc(func(cmd *cobra.Command, s []string) {
if cmd.HasInheritedFlags() { if cmd.HasInheritedFlags() {
cmd.InheritedFlags().VisitAll(func(f *pflag.Flag) { cmd.InheritedFlags().VisitAll(func(f *pflag.Flag) {
if f.Name != "logLevel" { if f.Name != "logLevel" {
@ -198,12 +198,12 @@ var fetchQuotaCmd = &cobra.Command{
Run: fetchQuota, Run: fetchQuota,
} }
var fetchCapacityCmd = &cobra.Command{ var fetchAvailCapacityCmd = &cobra.Command{
Use: "capacity", Use: "capacity",
PreRun: setConfig, PreRun: setConfig,
Short: "Fetch capacity report", Short: "Fetch capacity report",
Long: `This command will show detailed capacity report of the cluster`, Long: `This command will show detailed capacity report of the cluster`,
Run: fetchCapacity, Run: fetchAvailCapacity,
} }
func fetchTasksConfig(cmd *cobra.Command, args []string) { func fetchTasksConfig(cmd *cobra.Command, args []string) {
@ -440,9 +440,9 @@ func fetchQuota(cmd *cobra.Command, args []string) {
} }
} }
//fetchCapacity reports free capacity in details //fetchAvailCapacity reports free capacity in details
func fetchCapacity(cmd *cobra.Command, args []string) { func fetchAvailCapacity(cmd *cobra.Command, args []string) {
log.Infof("Fetching capacity from %s/offers\n", client.GetSchedulerURL()) log.Infof("Fetching available capacity from %s/offers\n", client.GetSchedulerURL())
report, err := client.AvailOfferReport() report, err := client.AvailOfferReport()
if err != nil { if err != nil {