mirror of
https://github.com/hanzoai/runtime.git
synced 2026-10-30 18:23:13 +00:00
- Add main Dockerfile for production builds - Add Dockerfile.runtime for secure code execution - Add Dockerfile.runtime.fixed with improved configuration - Include .dockerignore for build optimization - Add integration documentation and publishing guides - Update API and CLI components for better runtime support - Enhance sandbox and container management features
79 lines
1.8 KiB
Go
79 lines
1.8 KiB
Go
// Copyright 2025 Hanzo Industries Inc.
|
|
// SPDX-License-Identifier: AGPL-3.0
|
|
|
|
package sandbox
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hanzoai/runtime/cli/apiclient"
|
|
"github.com/hanzoai/runtime/cli/cmd/common"
|
|
"github.com/hanzoai/runtime/cli/config"
|
|
"github.com/hanzoai/runtime/cli/views/sandbox"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
verboseFlag bool
|
|
pageFlag int
|
|
limitFlag int
|
|
)
|
|
|
|
var ListCmd = &cobra.Command{
|
|
Use: "list",
|
|
Short: "List sandboxes",
|
|
Args: cobra.NoArgs,
|
|
Aliases: common.GetAliases("list"),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
ctx := context.Background()
|
|
|
|
apiClient, err := apiclient.GetApiClient(nil, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
sandboxList, res, err := apiClient.SandboxAPI.ListSandboxes(ctx).Verbose(verboseFlag).Execute()
|
|
if err != nil {
|
|
return apiclient.HandleErrorResponse(res, err)
|
|
}
|
|
|
|
sandbox.SortSandboxes(&sandboxList)
|
|
|
|
start := (pageFlag - 1) * limitFlag
|
|
end := start + limitFlag
|
|
if start > len(sandboxList) {
|
|
start = len(sandboxList)
|
|
}
|
|
if end > len(sandboxList) {
|
|
end = len(sandboxList)
|
|
}
|
|
paginatedList := sandboxList[start:end]
|
|
|
|
if common.FormatFlag != "" {
|
|
formattedData := common.NewFormatter(sandboxList)
|
|
formattedData.Print()
|
|
return nil
|
|
}
|
|
|
|
var activeOrganizationName *string
|
|
|
|
if !config.IsApiKeyAuth() {
|
|
name, err := common.GetActiveOrganizationName(apiClient, ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
activeOrganizationName = &name
|
|
}
|
|
|
|
sandbox.ListSandboxes(paginatedList, activeOrganizationName)
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
ListCmd.Flags().BoolVarP(&verboseFlag, "verbose", "v", false, "Include verbose output")
|
|
ListCmd.Flags().IntVarP(&pageFlag, "page", "p", 1, "Page number for pagination (starting from 1)")
|
|
ListCmd.Flags().IntVarP(&limitFlag, "limit", "l", 100, "Maximum number of items per page")
|
|
common.RegisterFormatFlag(ListCmd)
|
|
}
|