Fetch (pagination/pagination.go)

devops-ai-guidelines · 02-mcp-for-devops/code/08/pkg/pagination/pagination.go · go · MIT
infra

Generic pagination helpers for Kubernetes API listings.

// Source: https://github.com/VersusControl/devops-ai-guidelines | License: MIT | Copyright 2025 VersusControl
// Provided via justclaw.it.com; keep this notice with the code.
// Package pagination converts MCP tool arguments into Kubernetes
// ListOptions and back-paginates large result sets transparently.
package pagination

import (
	"context"
	"encoding/base64"
	"errors"
	"fmt"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Options describes how a caller wants to slice a list.
type Options struct {
	Limit         int64
	ContinueToken string
	LabelSelector string
	FieldSelector string
}

// Page is one chunk of results with the cursor for the next page.
type Page[T any] struct {
	Items         []T
	NextToken     string
	TotalReturned int
}

// Lister calls the Kubernetes API to r

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key