inspect

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

pkg/inspect/client.go

pkg/inspect/discovery.go

pkg/inspect/printer.go

pkg/inspect/reconcile_trigger.go

Index

Constants

View Source
const ReconcileAnnotation = "orkestra.konductor.io/reconcile-at"

ReconcileAnnotation is the annotation key written to trigger reconciliation. Orkestra's informer detects the metadata update and re-queues the object. The value is an RFC3339 timestamp — unique per trigger, readable in kubectl describe.

Variables

This section is empty.

Functions

func Bold

func Bold(s string) string

Bold wraps text in bold ANSI codes.

func Cyan

func Cyan(s string) string

Cyan wraps text in cyan ANSI codes.

func ExtractStatus

func ExtractStatus(obj *unstructured.Unstructured) string

ExtractStatus extracts a status phase or condition from an unstructured object. Returns "Unknown" if no status is found.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration in human-readable short form. Exported so CLI commands and tests can use it directly.

func HealthIcon

func HealthIcon(status string) string

HealthIcon returns a coloured status icon based on a status string.

func HumanAge

func HumanAge(t metav1.Time) string

HumanAge returns a human-readable age string from a Kubernetes timestamp. Format matches kubectl: 5s, 2m, 3h, 4d, 2w

func PrintError

func PrintError(msg string)

PrintError prints a red error line.

func PrintField

func PrintField(label, value string)

PrintField prints a label: value line used in describe output.

func PrintInfo

func PrintInfo(msg string)

PrintInfo prints a dim informational line.

func PrintNestedMap

func PrintNestedMap(m map[string]interface{}, indent int)

PrintNestedMap prints a nested map as indented key: value lines. Used by describe to print spec and status sections.

func PrintSection

func PrintSection(title string)

PrintSection prints a bold section header with a separator.

func PrintSuccess

func PrintSuccess(msg string)

PrintSuccess prints a green checkmark line.

func PrintTable

func PrintTable(w io.Writer, header []string, rows [][]string)

PrintTable prints a header + rows to stdout, flushed and aligned.

func PrintWarning

func PrintWarning(msg string)

PrintWarning prints a yellow warning line.

func TriggerReconcile

func TriggerReconcile(
	ctx context.Context,
	client dynamic.Interface,
	gvr schema.GroupVersionResource,
	namespace string,
	name string,
) error

TriggerReconcile patches the reconcile annotation on a single CR. The informer detects the metadata change and re-queues the object into the workqueue, causing Orkestra to reconcile it on the next loop.

This is non-destructive — it only touches the annotation, never the spec.

Types

type CRDInfo

type CRDInfo struct {
	// Name — CRD name e.g. "website"
	Name string

	// Group — API group e.g. "demo.orkestra.io"
	Group string

	// Version — API version e.g. "v1alpha1"
	Version string

	// Kind — singular Kind e.g. "Website"
	Kind string

	// Plural — plural resource name e.g. "websites"
	Plural string

	// Namespaced — true if the CRD is namespace-scoped
	Namespaced bool

	// GVR — the GroupVersionResource used by the dynamic client
	GVR schema.GroupVersionResource
}

CRDInfo holds the resolved GVR and display metadata for one CRD. Discovered from the cluster via the API server resource list.

func DiscoverCRD

func DiscoverCRD(disc discovery.DiscoveryInterface, name string) (*CRDInfo, error)

DiscoverCRD finds a CRD by name in the cluster.

The input may be any of:

  • plural resource name: "websites"
  • singular resource name: "website"
  • Kind (case-insensitive): "Website" or "website"

Returns an error if zero or more than one CRD matches. When multiple matches are found, all candidates are listed in the error so the user can be more specific.

func DiscoverOrkestraCRDs

func DiscoverOrkestraCRDs(disc discovery.DiscoveryInterface) ([]CRDInfo, error)

DiscoverOrkestraCRDs returns all CRDs in the cluster that carry the managed-by=orkestra label. Used by `ork reconcile all` when no --katalog is provided — discovers what Orkestra is already managing from the cluster rather than requiring a Katalog file.

type Clients

type Clients struct {
	// Dynamic — for reading any CRD as unstructured.Unstructured.
	// Used by get, describe, and reconcile commands.
	Dynamic dynamic.Interface

	// Discovery — for listing CRDs and resolving GVR from a name.
	// Used by all commands to discover what the user is referring to.
	Discovery discovery.DiscoveryInterface

	// Core — for reading Kubernetes events.
	// Used by describe and events commands.
	Core kubernetes.Interface

	// RestConfig — raw REST config, kept for any future direct REST calls.
	RestConfig *rest.Config
}

Clients holds the Kubernetes clients needed by all inspect commands. Built once, shared across all operations within a single command invocation.

func NewClients

func NewClients(kubeconfigPath string) (*Clients, error)

NewClients builds Kubernetes clients from the provided kubeconfig path.

Resolution order:

  1. Explicit kubeconfigPath argument (from --kubeconfig flag)
  2. KUBECONFIG environment variable
  3. ~/.kube/config (default kubeconfig location)
  4. In-cluster config (when running inside Kubernetes)

Returns a clear error if none of these paths produce a valid config.

type TableWriter

type TableWriter struct {
	// contains filtered or unexported fields
}

TableWriter wraps tabwriter for consistent aligned output.

func NewTableWriter

func NewTableWriter() *TableWriter

NewTableWriter returns a TableWriter writing to stdout.

func (*TableWriter) Flush

func (t *TableWriter) Flush()

Flush flushes the tabwriter buffer.

func (*TableWriter) Header

func (t *TableWriter) Header(cols ...string)

Header prints a bold header row.

func (*TableWriter) Row

func (t *TableWriter) Row(cols ...string)

Row prints one data row.

type TriggerResult

type TriggerResult struct {
	// Name — the CR name that was triggered
	Name string

	// Namespace — the CR namespace (empty for cluster-scoped)
	Namespace string

	// Error — non-nil if the trigger failed
	Error error
}

TriggerResult holds the outcome of one reconcile trigger operation.

func TriggerReconcileAll

func TriggerReconcileAll(
	ctx context.Context,
	client dynamic.Interface,
	gvr schema.GroupVersionResource,
	namespace string,
) ([]TriggerResult, error)

TriggerReconcileAll triggers reconciliation for every CR of a given CRD. Returns one TriggerResult per CR — failures are collected, not fatal. The caller decides how to handle partial failures.

Jump to

Keyboard shortcuts

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