Documentation
¶
Overview ¶
Package client provides dynamic Kubernetes client utilities.
Index ¶
- Constants
- Variables
- func EdgeGVRForType(edgeType string) schema.GroupVersionResource
- func EdgeKindForType(edgeType string) string
- func EdgeTypeForGVR(gvr schema.GroupVersionResource) string
- type Client
- func (c *Client) Dynamic() dynamic.Interface
- func (c *Client) Grants() *TypedResource[tenancyv1alpha1.Grant, tenancyv1alpha1.GrantList]
- func (c *Client) Organizations() *TypedResource[tenancyv1alpha1.Organization, tenancyv1alpha1.OrganizationList]
- func (c *Client) UserMembershipIndices() ...
- func (c *Client) UserPreferences() ...
- func (c *Client) Users() *TypedResource[tenancyv1alpha1.User, tenancyv1alpha1.UserList]
- type InformerFactory
- type TypedResource
- func (r *TypedResource[T, L]) Create(ctx context.Context, obj *T, opts metav1.CreateOptions) (*T, error)
- func (r *TypedResource[T, L]) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
- func (r *TypedResource[T, L]) Get(ctx context.Context, name string, opts metav1.GetOptions) (*T, error)
- func (r *TypedResource[T, L]) List(ctx context.Context, opts metav1.ListOptions) (*L, error)
- func (r *TypedResource[T, L]) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, ...) (*T, error)
- func (r *TypedResource[T, L]) Update(ctx context.Context, obj *T, opts metav1.UpdateOptions) (*T, error)
- func (r *TypedResource[T, L]) UpdateStatus(ctx context.Context, obj *T, opts metav1.UpdateOptions) (*T, error)
Constants ¶
const ( // DefaultResyncPeriod is the default resync period for informers. DefaultResyncPeriod = 10 * time.Minute )
Variables ¶
var ( // KubernetesClusterGVR addresses the edges provider's KubernetesCluster kind // (cluster-scoped). KubernetesClusterGVR = schema.GroupVersionResource{ Group: "edges.railgrid.ai", Version: "v1alpha1", Resource: "kubernetesclusters", } // LinuxServerGVR addresses the edges provider's LinuxServer kind // (cluster-scoped). LinuxServerGVR = schema.GroupVersionResource{ Group: "edges.railgrid.ai", Version: "v1alpha1", Resource: "linuxservers", } // MacOSServerGVR addresses the edges provider's MacOSServer kind // (cluster-scoped). MacOSServerGVR = schema.GroupVersionResource{ Group: "edges.railgrid.ai", Version: "v1alpha1", Resource: "macosservers", } // WorkloadGVR addresses the edges provider's Workload kind // (namespaced): a workload scheduled across matching KubernetesCluster edges. WorkloadGVR = schema.GroupVersionResource{ Group: "edges.railgrid.ai", Version: "v1alpha1", Resource: "workloads", } // PlacementGVR addresses the edges provider's Placement kind (namespaced): // one Workload placed on one edge. PlacementGVR = schema.GroupVersionResource{ Group: "edges.railgrid.ai", Version: "v1alpha1", Resource: "placements", } // UserGVR points at the new tenants.railgrid.ai User CRD. PRs // #204-#207 introduced the tenants.railgrid.ai group; this GVR // previously pointed at the legacy railgrid.ai 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.railgrid.ai. UserGVR = schema.GroupVersionResource{ Group: "tenants.railgrid.ai", 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.railgrid.ai", Version: "v1alpha1", Resource: "usermembershipindices", } // GrantGVR points at the cluster-scoped Grant CRD (see // apis/tenancy/v1alpha1/types_grant.go): the capabilities a tenant // accepted for a subject (today: a provider) in a workspace. Lives in // root:railgrid:system:tenants beside the UMI. GrantGVR = schema.GroupVersionResource{ Group: "tenants.railgrid.ai", Version: "v1alpha1", Resource: "grants", } // 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:railgrid:users. OrganizationGVR = schema.GroupVersionResource{ Group: "tenants.railgrid.ai", 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.railgrid.ai", Version: "v1alpha1", Resource: "userpreferences", } )
Functions ¶
func EdgeGVRForType ¶
func EdgeGVRForType(edgeType string) schema.GroupVersionResource
EdgeGVRForType maps an edge type ("kubernetes" | "server" | "macos") to the connectable resource's GVR. Unknown and empty types retain the historic KubernetesCluster default.
func EdgeKindForType ¶
EdgeKindForType returns the Kubernetes kind corresponding to an agent edge type. It is kept next to EdgeGVRForType so callers cannot accidentally map a resource to the wrong kind when constructing an unstructured object.
func EdgeTypeForGVR ¶
func EdgeTypeForGVR(gvr schema.GroupVersionResource) string
EdgeTypeForGVR returns the CLI/agent type for a connectable resource GVR. Unknown resources retain the Kubernetes default for backwards compatibility with callers that historically treated every non-server edge as Kubernetes.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides typed access to railgrid custom resources via the dynamic client.
func NewForConfig ¶
NewForConfig creates a new Client for the given rest config.
func NewFromDynamic ¶
NewFromDynamic creates a new Client from an existing dynamic.Interface.
func (*Client) Grants ¶
func (c *Client) Grants() *TypedResource[tenancyv1alpha1.Grant, tenancyv1alpha1.GrantList]
Grants returns a typed interface for the cluster-scoped Grant CRD. The provider Enable flow writes grants and the hub-access gate reads them to authorize a provider's delegated token.
func (*Client) Organizations ¶
func (c *Client) Organizations() *TypedResource[tenancyv1alpha1.Organization, tenancyv1alpha1.OrganizationList]
Organizations returns a typed interface for the cluster-scoped Organization CRD. Used by the step 10 REST surface.
func (*Client) UserMembershipIndices ¶
func (c *Client) UserMembershipIndices() *TypedResource[tenancyv1alpha1.UserMembershipIndex, tenancyv1alpha1.UserMembershipIndexList]
UserMembershipIndices returns a typed interface for the UMI CRD (cluster-scoped). One UMI per User; the tenant middleware uses this to authorise X-Railgrid-Org / X-Railgrid-Workspace headers on every /api/* request.
func (*Client) UserPreferences ¶
func (c *Client) UserPreferences() *TypedResource[tenancyv1alpha1.UserPreferences, tenancyv1alpha1.UserPreferencesList]
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 ¶
func (c *Client) Users() *TypedResource[tenancyv1alpha1.User, tenancyv1alpha1.UserList]
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 railgrid 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 railgrid resources.
func (*InformerFactory) ForResource ¶
func (f *InformerFactory) ForResource(gvr schema.GroupVersionResource) informers.GenericInformer
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 ¶
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.