Skip to content

Commit de9239b

Browse files
committed
added: limitBytes input when reading logs
1 parent a628d5d commit de9239b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/tools/pod_logs.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func NewPodLogsTool(pool k8s.ClientPool) fxctx.Tool {
2424
toolinput.WithRequiredString("pod", "Name of the pod to get logs from"),
2525
toolinput.WithString("sinceDuration", "Only return logs newer than a relative duration like 5s, 2m, or 3h. Only one of sinceTime or sinceDuration may be set."),
2626
toolinput.WithString("sinceTime", "Only return logs after a specific date (RFC3339). Only one of sinceTime or sinceDuration may be set."),
27+
toolinput.WithNumber("limitBytes", "Maximum bytes of logs to return. Defaults to no limit."),
2728
toolinput.WithBoolean("previousContainer", "Return previous terminated container logs, defaults to false."),
2829
)
2930
return fxctx.NewTool(
@@ -53,6 +54,10 @@ func NewPodLogsTool(pool k8s.ClientPool) fxctx.Tool {
5354
return errResponse(fmt.Errorf("invalid input: %w", err))
5455
}
5556

57+
var noLimit int64 = -1
58+
limitBytesF64 := input.NumberOr("limitBytes", float64(noLimit))
59+
limitBytes := int64(limitBytesF64)
60+
5661
sinceDurationStr := input.StringOr("sinceDuration", "")
5762

5863
sinceTimeStr := ""
@@ -68,6 +73,9 @@ func NewPodLogsTool(pool k8s.ClientPool) fxctx.Tool {
6873
options := &v1.PodLogOptions{
6974
Previous: previousContainer,
7075
}
76+
if limitBytes != noLimit {
77+
options.LimitBytes = &limitBytes
78+
}
7179
if sinceDurationStr != "" {
7280
sinceDuration, err := time.ParseDuration(sinceDurationStr)
7381
if err != nil {

0 commit comments

Comments
 (0)