func listAllocators()

in cmd/platform/allocator/list.go [60:90]


func listAllocators(cmd *cobra.Command, args []string) error {
	var queryString = cmd.Flag("query").Value.String()
	if unhealthy, _ := cmd.Flags().GetBool("unhealthy"); unhealthy {
		queryString = allocatorapi.UnhealthyQuery
	}

	allFlag, _ := strconv.ParseBool(cmd.Flag("all").Value.String())
	size, _ := cmd.Flags().GetInt("size")
	a, err := allocatorapi.List(allocatorapi.ListParams{
		API:        ecctl.Get().API,
		Query:      queryString,
		FilterTags: cmd.Flag("filter").Value.String(),
		ShowAll:    allFlag,
		Size:       int64(size),
		Region:     ecctl.Get().Config.Region,
	})
	if err != nil {
		return err
	}

	templateName := "list"
	if metadata, _ := cmd.Flags().GetBool("metadata"); metadata {
		templateName = "listmetadata"
	}

	if cmd.Flag("output").Value.String() != "json" && !allFlag {
		fmt.Printf("Showing allocators that have instances or are connected in the platform. Use --all flag or --output json to show all\n")
	}

	return ecctl.Get().Formatter.Format(filepath.Join("allocator", templateName), a)
}