client

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package client provides dynamic Kubernetes client utilities.

Index

Constants

View Source
const (
	// DefaultResyncPeriod is the default resync period for informers.
	DefaultResyncPeriod = 10 * time.Minute
)

Variables

View Source
var (
	// KubernetesClusterGVR addresses the edges provider's KubernetesCluster kind
	// (cluster-scoped).
	KubernetesClusterGVR = schema.GroupVersionResource{
		Group:    "edges.faros.sh",
		Version:  "v1alpha1",
		Resource: "kubernetesclusters",
	}
	// LinuxServerGVR addresses the edges provider's LinuxServer kind
	// (cluster-scoped).
	LinuxServerGVR = schema.GroupVersionResource{
		Group:    "edges.faros.sh",
		Version:  "v1alpha1",
		Resource: "linuxservers",
	}
	// WorkloadGVR addresses the edges provider's Workload kind
	// (namespaced): a workload scheduled across matching KubernetesCluster edges.
	WorkloadGVR = schema.GroupVersionResource{
		Group:    "edges.faros.sh",
		Version:  "v1alpha1",
		Resource: "workloads",
	}
	// PlacementGVR addresses the edges provider's Placement kind (namespaced):
	// one Workload placed on one edge.
	PlacementGVR = schema.GroupVersionResource{
		Group:    "edges.faros.sh",
		Version:  "v1alpha1",
		Resource: "placements",
	}

	// UserGVR points at the new tenants.faros.sh User CRD. PRs
	// #204-#207 introduced the tenants.faros.sh group; this GVR
	// previously pointed at the legacy faros.sh group, which left
	// User writes from the auth handler invisible to the org bootstrap
	// controller (which watches the new group). Migration in roadmap
	// step 7+ aligns both sides on tenants.faros.sh.
	UserGVR = schema.GroupVersionResource{
		Group:    "tenants.faros.sh",
		Version:  "v1alpha1",
		Resource: "users",
	}

	// UserMembershipIndexGVR points at the cluster-scoped UMI CRD
	// (see apis/tenancy/v1alpha1/types_user_membership_index.go).
	// One UMI per User; the tenant middleware reads this on every
	// request to authorise (Org, Workspace) header pairs.
	UserMembershipIndexGVR = schema.GroupVersionResource{
		Group:    "tenants.faros.sh",
		Version:  "v1alpha1",
		Resource: "usermembershipindices",
	}

	// OrganizationGVR points at the cluster-scoped Organization CRD
	// (see apis/tenancy/v1alpha1/types_organization.go). Used by the
	// step 10 REST surface for Org CRUD against root:faros:users.
	OrganizationGVR = schema.GroupVersionResource{
		Group:    "tenants.faros.sh",
		Version:  "v1alpha1",
		Resource: "organizations",
	}

	// UserPreferencesGVR points at the cluster-scoped UserPreferences CRD
	// (see apis/tenancy/v1alpha1/types_user_preferences.go). One object per
	// User; the portal's dashboard-layout REST handlers read/write it to
	// remember each workspace's tile arrangement across browsers.
	UserPreferencesGVR = schema.GroupVersionResource{
		Group:    "tenants.faros.sh",
		Version:  "v1alpha1",
		Resource: "userpreferences",
	}
)

Functions

func EdgeGVRForType

func EdgeGVRForType(edgeType string) schema.GroupVersionResource

EdgeGVRForType maps an edge type ("kubernetes" | "server") to the connectable resource's GVR. Server edges map to LinuxServer; everything else (default) maps to KubernetesCluster.

Types

type Client

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

Client provides typed access to faros custom resources via the dynamic client.

func NewForConfig

func NewForConfig(config *rest.Config) (*Client, error)

NewForConfig creates a new Client for the given rest config.

func NewFromDynamic

func NewFromDynamic(d dynamic.Interface) *Client

NewFromDynamic creates a new Client from an existing dynamic.Interface.

func (*Client) Dynamic

func (c *Client) Dynamic() dynamic.Interface

Dynamic returns the underlying dynamic client.

func (*Client) Organizations

Organizations returns a typed interface for the cluster-scoped Organization CRD. Used by the step 10 REST surface.

func (*Client) UserMembershipIndices

UserMembershipIndices returns a typed interface for the UMI CRD (cluster-scoped). One UMI per User; the tenant middleware uses this to authorise X-Faros-Org / X-Faros-Workspace headers on every /api/* request.

func (*Client) UserPreferences

UserPreferences returns a typed interface for the cluster-scoped UserPreferences CRD (one per User). Used by the portal's dashboard layout REST handlers to persist tile arrangement per workspace.

func (*Client) Users

Users returns a typed interface for User resources (cluster-scoped).

type InformerFactory

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

InformerFactory wraps a dynamic shared informer factory and provides convenience methods for getting informers for faros resources.

func NewFilteredInformerFactory

func NewFilteredInformerFactory(client dynamic.Interface, resyncPeriod time.Duration, namespace string, tweakListOptions dynamicinformer.TweakListOptionsFunc) *InformerFactory

NewFilteredInformerFactory creates a new InformerFactory with list option tweaks.

func NewInformerFactory

func NewInformerFactory(client dynamic.Interface, resyncPeriod time.Duration) *InformerFactory

NewInformerFactory creates a new InformerFactory for faros resources.

func (*InformerFactory) ForResource

ForResource returns a SharedIndexInformer for a specific GVR.

func (*InformerFactory) Start

func (f *InformerFactory) Start(stopCh <-chan struct{})

Start starts all informers.

func (*InformerFactory) WaitForCacheSync

func (f *InformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[schema.GroupVersionResource]bool

WaitForCacheSync waits for all informer caches to sync.

type TypedResource

type TypedResource[T any, L any] struct {
	// contains filtered or unexported fields
}

TypedResource provides typed CRUD operations for a specific resource type. gvk is used to populate apiVersion/kind on objects before sending them to the dynamic client. The Go structs have TypeMeta tagged `omitempty`, so callers that forget to set apiVersion/kind would otherwise produce a JSON payload missing both fields — which the API server rejects with "Object 'Kind' is missing".

func (*TypedResource[T, L]) Create

func (r *TypedResource[T, L]) Create(ctx context.Context, obj *T, opts metav1.CreateOptions) (*T, error)

Create creates a new resource.

func (*TypedResource[T, L]) Delete

func (r *TypedResource[T, L]) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error

Delete removes a resource by name.

func (*TypedResource[T, L]) Get

func (r *TypedResource[T, L]) Get(ctx context.Context, name string, opts metav1.GetOptions) (*T, error)

Get retrieves a resource by name.

func (*TypedResource[T, L]) List

func (r *TypedResource[T, L]) List(ctx context.Context, opts metav1.ListOptions) (*L, error)

List retrieves all resources matching the given options.

func (*TypedResource[T, L]) Patch

func (r *TypedResource[T, L]) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*T, error)

Patch applies a patch to a resource.

func (*TypedResource[T, L]) Update

func (r *TypedResource[T, L]) Update(ctx context.Context, obj *T, opts metav1.UpdateOptions) (*T, error)

Update updates an existing resource.

func (*TypedResource[T, L]) UpdateStatus

func (r *TypedResource[T, L]) UpdateStatus(ctx context.Context, obj *T, opts metav1.UpdateOptions) (*T, error)

UpdateStatus updates the status subresource.

Jump to

Keyboard shortcuts

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