Help us shape the future of Go! Take the 2026 Go Developer Survey

api

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultListLimit is applied when a caller doesn't specify one.
	DefaultListLimit = 100
	// MaxListLimit bounds every list call regardless of what a caller asks
	// for, so a single tool call can't dump an unbounded collection into
	// model context. Callers that want more follow the continue token.
	MaxListLimit = 500
)

Variables

This section is empty.

Functions

func CleanList

func CleanList(list *unstructured.UnstructuredList) []map[string]any

CleanList returns cleaned copies of every item in list, in order.

func CleanObject

func CleanObject(obj *unstructured.Unstructured) map[string]any

CleanObject returns a shallow copy of obj's fields with internal-only Kubernetes metadata stripped. spec, status, name, namespace, labels, and annotations are preserved in full.

func CreateObject

func CreateObject(ctx context.Context, cli ctrlclient.Client, group, kind, namespace string, in any, opts WriteOptions) (*unstructured.Unstructured, error)

func DeleteObject

func DeleteObject(ctx context.Context, cli ctrlclient.Client, group, kind, namespace, name string, opts WriteOptions) error

func FetchAllItems

func FetchAllItems(ctx context.Context, cli ctrlclient.Client, group, kind, namespace string) ([]unstructured.Unstructured, error)

FetchAllItems fetches every item of a kind across all pages, following the continuation token until the server reports none remain. Use this only where correctness requires seeing the complete set regardless of size (e.g. membership verification) — everywhere else, prefer FetchList with caller-controlled pagination so a single tool call can't be made to pull an unbounded collection into model context.

func FetchList

func FetchList(ctx context.Context, cli ctrlclient.Client, group, kind, namespace string, opts ListOptions) (*unstructured.UnstructuredList, error)

func FetchObject

func FetchObject(ctx context.Context, cli ctrlclient.Client, group, kind, namespace, name string) (*unstructured.Unstructured, error)

Generic unstructured helpers using the shared RESTMapper

func GetResourceDefinition

func GetResourceDefinition(ctx context.Context, project, group, version, kind string, structureOnly bool, out any) error

Discovery: CRD schema via OpenAPI v3 direct path: /openapi/v3/apis/<group>/<version>[/<kind>] When structureOnly is true, the schema is reduced to its structural shape (types, properties, required, items, additionalProperties, oneOf/anyOf/allOf) to save context; descriptions, formats, and examples are dropped.

func ListResourceDefinitions

func ListResourceDefinitions(ctx context.Context, project string, out any) error

List CRDs under the project control-plane

func NewOrgControlPlaneClient

func NewOrgControlPlaneClient(ctx context.Context, org string) (ctrlclient.Client, error)

func NewProjectControlPlaneClient

func NewProjectControlPlaneClient(ctx context.Context, project string) (ctrlclient.Client, error)

func NewProjectHTTPClient

func NewProjectHTTPClient(ctx context.Context, project string) (*http.Client, string, error)

NewProjectHTTPClient returns an HTTP client whose transport injects Authorization and the project control-plane base path prefix. Use with absolute URLs like "https://host" + path.

func NewProjectRESTConfig added in v0.2.3

func NewProjectRESTConfig(ctx context.Context, project string) (*rest.Config, error)

NewProjectRESTConfig returns the rest.Config a project control-plane client is built from, for code that issues its own requests against that control plane's other APIs (e.g. the project logs API).

func NewProjectTypedClient added in v0.2.3

func NewProjectTypedClient(ctx context.Context, project string, scheme *runtime.Scheme) (ctrlclient.Client, error)

NewProjectTypedClient is NewProjectControlPlaneClient decoding into the typed objects scheme registers, for code that reads typed objects rather than unstructured ones (e.g. the alb toolset).

func NewUserControlPlaneClient

func NewUserControlPlaneClient(ctx context.Context, userID string) (ctrlclient.Client, error)

func UpdateObjectSpec

func UpdateObjectSpec(ctx context.Context, cli ctrlclient.Client, group, kind, namespace, name string, in any, opts WriteOptions) (*unstructured.Unstructured, error)

Types

type ConflictError

type ConflictError struct {
	Kind string
	Name string
}

ConflictError is returned by UpdateObjectSpec when a caller supplies ExpectedResourceVersion and the resource has since changed.

func (*ConflictError) Error

func (e *ConflictError) Error() string

type ListOptions

type ListOptions struct {
	Limit         int64
	Continue      string
	LabelSelector string
	FieldSelector string
}

ListOptions bounds and filters a FetchList call. LabelSelector and FieldSelector use the same string syntax as kubectl (e.g. "team=edge", "metadata.name=foo").

type WriteOptions

type WriteOptions struct {
	// DryRun asks the server to validate and run admission without
	// persisting the change. Standard Kubernetes apiserver behavior; not
	// guaranteed for every custom controller's reconciliation path.
	DryRun bool
	// ExpectedResourceVersion, for update/delete only: when non-empty, the
	// operation fails with a *ConflictError instead of proceeding if the
	// resource's current resourceVersion doesn't match. Empty means no
	// check (last-write-wins), which is the pre-existing behavior.
	ExpectedResourceVersion string
}

WriteOptions controls create/update/delete behavior.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL