mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-09-30 03:51:43 +02:00
Add pagination support for listing VM events (#386)
* Add pagination support for listing VM events Introduced a paginated event listing API, added support for pagination parameters in the request, and included cursor-based navigation using headers. Relevant tests and Badger store implementations were updated to support the new logic. * Remove support for ordering VM events Dropped `ListOrder` type, `order` query parameter, and related logic for ordering VM events. Updated tests, API schema, and Badger store to reflect the removal. * Remove invalid VM events ordering test Deleted a test case for invalid VM events ordering since the `order` query parameter and related functionality have been removed. * Add support for ordering VM events Implemented `order` query parameter for specifying sort order (ascending/descending) of VM events. Updated API schema, Badger store, and added related tests. * Add support for limiting and ordering VM logs Introduced `--limit` and `--order` flags for controlling the number of log lines and their sort order (ascending/descending). Updated API client to handle new options. * Update internal/controller/store/badger/badger_events.go Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com> * fix: address PR review feedback - switch logs CLI to --tail with desc ordering - reuse ParseLogsOrder in controller with helpful errors - always use ListEventsPage and scope event cursors - move events pagination coverage to integration test 🤖 Generated with [Codex](https://chatgpt.com/codex) Co-Authored-By: Codex <codex@openai.com> * refactor: simplify prefix trimming and improve error formatting - Replaced manual prefix check with `bytes.TrimPrefix` in Badger store. - Enhanced error message formatting in VM logs controller. * fix: address PR review feedback - use suggested reverse seek in badger events pagination - add events pagination client helper and use it in integration test 🤖 Generated with [Codex](https://chatgpt.com/codex) Co-Authored-By: Codex <codex@openai.com> --------- Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com> Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
co-authored by
Codex
Nikolay Edigaryev
parent
ea89d01760
commit
6fe523ef69
@@ -2,10 +2,13 @@ package logs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cirruslabs/orchard/pkg/client"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var logTail int
|
||||
|
||||
func newLogsVMCommand() *cobra.Command {
|
||||
command := &cobra.Command{
|
||||
Use: "vm NAME",
|
||||
@@ -14,18 +17,26 @@ func newLogsVMCommand() *cobra.Command {
|
||||
Args: cobra.ExactArgs(1),
|
||||
}
|
||||
|
||||
command.Flags().IntVar(&logTail, "tail", 0, "Number of log lines to show from the end (newest first)")
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
func runLogsVM(cmd *cobra.Command, args []string) error {
|
||||
name := args[0]
|
||||
|
||||
client, err := client.New()
|
||||
apiClient, err := client.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
lines, err := client.VMs().Logs(cmd.Context(), name)
|
||||
options := client.LogsOptions{}
|
||||
if logTail > 0 {
|
||||
options.Limit = logTail
|
||||
options.Order = client.LogsOrderDesc
|
||||
}
|
||||
|
||||
lines, err := apiClient.VMs().LogsWithOptions(cmd.Context(), name, options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user