Documentation
¶
Overview ¶
Package sqlproxy implements the proxy store, which is responsible for either interfacing directly with the Kubernetes API, or in the case of List, interfacing with an on-disk cache of items in the Kubernetes API.
Index ¶
- Variables
- type Cache
- type CacheFactory
- type CacheFactoryInitializer
- type ClientGetter
- type RelationshipNotifier
- type SchemaCollection
- type SchemaColumnSetter
- type Store
- func (s *Store) AugmentRelationships(ctx context.Context, gvk schema.GroupVersionKind, ...) error
- func (s *Store) ByID(apiOp *types.APIRequest, schema *types.APISchema, id string) (*unstructured.Unstructured, []types.Warning, error)
- func (s *Store) Create(apiOp *types.APIRequest, schema *types.APISchema, params types.APIObject) (*unstructured.Unstructured, []types.Warning, error)
- func (s *Store) Delete(apiOp *types.APIRequest, schema *types.APISchema, id string) (*unstructured.Unstructured, []types.Warning, error)
- func (s *Store) ListByPartitions(apiOp *types.APIRequest, apiSchema *types.APISchema, ...) (list *unstructured.UnstructuredList, total int, summary *types.APISummary, ...)
- func (s *Store) Reset(gvk schema.GroupVersionKind) error
- func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params types.APIObject, ...) (*unstructured.Unstructured, []types.Warning, error)
- func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest) (chan watch.Event, error)
- func (s *Store) WatchByPartitions(apiOp *types.APIRequest, schema *types.APISchema, wr types.WatchRequest, ...) (chan watch.Event, error)
- func (s *Store) WatchNames(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest, ...) (chan watch.Event, error)
- type TransformBuilder
- type WarningBuffer
- type Watchers
Constants ¶
This section is empty.
Variables ¶
var TypeGuidanceTable = map[schema.GroupVersionKind]map[string]string{
{Group: "", Version: "v1", Kind: "Secret"}: {
"metadata.fields[2]": "INT",
},
{Group: "", Version: "v1", Kind: "ServiceAccount"}: {
"metadata.fields[1]": "INT",
},
{Group: "", Version: "v1", Kind: "ConfigMap"}: {
"metadata.fields[1]": "INT",
},
}
var ( // TypeSpecificIndexedFields maps GVK keys to their indexed fields. // The inner map key is the UI field identifier (what the UI sends for sorting/filtering). // The IndexedField.ColumnName() returns the SQL column name (currently always matches the key). // Please keep the gvkKey entries in alphabetical order, on a field-by-field basis TypeSpecificIndexedFields = map[string]map[string]informer.IndexedField{ gvkKey("", "v1", "Event"): { "_type": &informer.JSONPathField{Path: []string{"_type"}}, "involvedObject.kind": &informer.JSONPathField{Path: []string{"involvedObject", "kind"}}, "involvedObject.uid": &informer.JSONPathField{Path: []string{"involvedObject", "uid"}}, "message": &informer.JSONPathField{Path: []string{"message"}}, "reason": &informer.JSONPathField{Path: []string{"reason"}}, }, gvkKey("", "v1", "Namespace"): { "spec.displayName": &informer.JSONPathField{Path: []string{"spec", "displayName"}}, }, gvkKey("", "v1", "Node"): { "spec.taints.key": &informer.JSONPathField{Path: []string{"spec", "taints", "key"}}, "status.addresses.type": &informer.JSONPathField{Path: []string{"status", "addresses", "type"}}, "status.nodeInfo.kubeletVersion": &informer.JSONPathField{Path: []string{"status", "nodeInfo", "kubeletVersion"}}, "status.nodeInfo.operatingSystem": &informer.JSONPathField{Path: []string{"status", "nodeInfo", "operatingSystem"}}, }, gvkKey("", "v1", "PersistentVolume"): { "status.reason": &informer.JSONPathField{Path: []string{"status", "reason"}}, "spec.persistentVolumeReclaimPolicy": &informer.JSONPathField{Path: []string{"spec", "persistentVolumeReclaimPolicy"}}, }, gvkKey("", "v1", "PersistentVolumeClaim"): { "spec.volumeName": &informer.JSONPathField{Path: []string{"spec", "volumeName"}}, }, gvkKey("", "v1", "Pod"): { "metadata.state.error": &informer.JSONPathField{Path: []string{"metadata", "state", "error"}}, "metadata.state.message": &informer.JSONPathField{Path: []string{"metadata", "state", "message"}}, "metadata.state.transitioning": &informer.JSONPathField{Path: []string{"metadata", "state", "transitioning"}}, "spec.containers.image": &informer.JSONPathField{Path: []string{"spec", "containers", "image"}}, "spec.nodeName": &informer.JSONPathField{Path: []string{"spec", "nodeName"}}, "status.podIP": &informer.JSONPathField{Path: []string{"status", "podIP"}}, "metadata.fields[3]": &informer.ComputedField{ Name: "metadata.fields[3]_0", Type: "INTEGER", GetValueFunc: informer.ExtractPodRestartCount, }, "metadata.fields[3][0]": &informer.ComputedField{ Name: "metadata.fields[3]_0", Type: "INTEGER", GetValueFunc: informer.ExtractPodRestartCount, }, "metadata.fields[3][1]": &informer.ComputedField{ Name: "metadata.fields[3]_1", Type: "INTEGER", GetValueFunc: informer.ExtractPodRestartTimestamp, }, }, gvkKey("", "v1", "ReplicationController"): { "spec.template.spec.containers.image": &informer.JSONPathField{Path: []string{"spec", "template", "spec", "containers", "image"}}, }, gvkKey("", "v1", "Secret"): { "_type": &informer.JSONPathField{Path: []string{"_type"}}, "metadata.annotations[management.cattle.io/project-scoped-secret-copy]": &informer.JSONPathField{Path: []string{"metadata", "annotations", "management.cattle.io/project-scoped-secret-copy"}}, "spec.clusterName": &informer.JSONPathField{Path: []string{"spec", "clusterName"}}, "spec.displayName": &informer.JSONPathField{Path: []string{"spec", "displayName"}}, }, gvkKey("", "v1", "Service"): { "spec.clusterIP": &informer.JSONPathField{Path: []string{"spec", "clusterIP"}}, "spec.type": &informer.JSONPathField{Path: []string{"spec", "type"}}, }, gvkKey("apps", "v1", "DaemonSet"): { "metadata.annotations[field.cattle.io/publicEndpoints]": &informer.JSONPathField{Path: []string{"metadata", "annotations", "field.cattle.io/publicEndpoints"}}, "spec.template.spec.containers.image": &informer.JSONPathField{Path: []string{"spec", "template", "spec", "containers", "image"}}, }, gvkKey("apps", "v1", "Deployment"): { "metadata.annotations[field.cattle.io/publicEndpoints]": &informer.JSONPathField{Path: []string{"metadata", "annotations", "field.cattle.io/publicEndpoints"}}, "spec.template.spec.containers.image": &informer.JSONPathField{Path: []string{"spec", "template", "spec", "containers", "image"}}, }, gvkKey("apps", "v1", "ReplicaSet"): { "spec.template.spec.containers.image": &informer.JSONPathField{Path: []string{"spec", "template", "spec", "containers", "image"}}, }, gvkKey("apps", "v1", "StatefulSet"): { "metadata.annotations[field.cattle.io/publicEndpoints]": &informer.JSONPathField{Path: []string{"metadata", "annotations", "field.cattle.io/publicEndpoints"}}, "spec.template.spec.containers.image": &informer.JSONPathField{Path: []string{"spec", "template", "spec", "containers", "image"}}, }, gvkKey("autoscaling", "v2", "HorizontalPodAutoscaler"): { "spec.scaleTargetRef.name": &informer.JSONPathField{Path: []string{"spec", "scaleTargetRef", "name"}}, "spec.minReplicas": &informer.JSONPathField{Path: []string{"spec", "minReplicas"}}, "spec.maxReplicas": &informer.JSONPathField{Path: []string{"spec", "maxReplicas"}}, "status.currentReplicas": &informer.JSONPathField{Path: []string{"status", "currentReplicas"}}, }, gvkKey("batch", "v1", "CronJob"): { "metadata.annotations[field.cattle.io/publicEndpoints]": &informer.JSONPathField{Path: []string{"metadata", "annotations", "field.cattle.io/publicEndpoints"}}, "spec.jobTemplate.spec.template.spec.containers.image": &informer.JSONPathField{Path: []string{"spec", "jobTemplate", "spec", "template", "spec", "containers", "image"}}, "status.lastScheduleTime": &informer.JSONPathField{Path: []string{"status", "lastScheduleTime"}}, "status.lastSuccessfulTime": &informer.JSONPathField{Path: []string{"status", "lastSuccessfulTime"}}, }, gvkKey("batch", "v1", "Job"): { "metadata.annotations[field.cattle.io/publicEndpoints]": &informer.JSONPathField{Path: []string{"metadata", "annotations", "field.cattle.io/publicEndpoints"}}, "metadata.state.error": &informer.JSONPathField{Path: []string{"metadata", "state", "error"}}, "metadata.state.message": &informer.JSONPathField{Path: []string{"metadata", "state", "message"}}, "metadata.state.transitioning": &informer.JSONPathField{Path: []string{"metadata", "state", "transitioning"}}, "spec.template.spec.containers.image": &informer.JSONPathField{Path: []string{"spec", "template", "spec", "containers", "image"}}, }, gvkKey("catalog.cattle.io", "v1", "App"): { "spec.chart.metadata.name": &informer.JSONPathField{Path: []string{"spec", "chart", "metadata", "name"}}, }, gvkKey("catalog.cattle.io", "v1", "ClusterRepo"): { "metadata.annotations[clusterrepo.cattle.io/hidden]": &informer.JSONPathField{Path: []string{"metadata", "annotations", "clusterrepo.cattle.io/hidden"}}, "spec.gitBranch": &informer.JSONPathField{Path: []string{"spec", "gitBranch"}}, "spec.gitRepo": &informer.JSONPathField{Path: []string{"spec", "gitRepo"}}, }, gvkKey("catalog.cattle.io", "v1", "Operation"): { "status.action": &informer.JSONPathField{Path: []string{"status", "action"}}, "status.namespace": &informer.JSONPathField{Path: []string{"status", "namespace"}}, "status.releaseName": &informer.JSONPathField{Path: []string{"status", "releaseName"}}, }, gvkKey("cluster.x-k8s.io", "v1beta1", "Machine"): { "spec.clusterName": &informer.JSONPathField{Path: []string{"spec", "clusterName"}}, }, gvkKey("cluster.x-k8s.io", "v1beta1", "MachineDeployment"): { "spec.clusterName": &informer.JSONPathField{Path: []string{"spec", "clusterName"}}, }, gvkKey("management.cattle.io", "v3", "Cluster"): { "spec.internal": &informer.JSONPathField{Path: []string{"spec", "internal"}}, "spec.displayName": &informer.JSONPathField{Path: []string{"spec", "displayName"}}, "status.allocatable.cpu": &informer.JSONPathField{Type: "", Path: []string{"status", "allocatable", "cpu"}}, "status.allocatable.cpuRaw": &informer.JSONPathField{Type: "REAL", Path: []string{"status", "allocatable", "cpuRaw"}}, "status.allocatable.memory": &informer.JSONPathField{Type: "", Path: []string{"status", "allocatable", "memory"}}, "status.allocatable.memoryRaw": &informer.JSONPathField{Type: "REAL", Path: []string{"status", "allocatable", "memoryRaw"}}, "status.allocatable.pods": &informer.JSONPathField{Type: "INT", Path: []string{"status", "allocatable", "pods"}}, "status.requested.cpu": &informer.JSONPathField{Type: "", Path: []string{"status", "requested", "cpu"}}, "status.requested.cpuRaw": &informer.JSONPathField{Type: "REAL", Path: []string{"status", "requested", "cpuRaw"}}, "status.requested.memory": &informer.JSONPathField{Type: "", Path: []string{"status", "requested", "memory"}}, "status.requested.memoryRaw": &informer.JSONPathField{Type: "REAL", Path: []string{"status", "requested", "memoryRaw"}}, "status.requested.pods": &informer.JSONPathField{Type: "INT", Path: []string{"status", "requested", "pods"}}, "status.connected": &informer.JSONPathField{Path: []string{"status", "connected"}}, "status.provider": &informer.JSONPathField{Path: []string{"status", "provider"}}, }, gvkKey("management.cattle.io", "v3", "ClusterRoleTemplateBinding"): { "clusterName": &informer.JSONPathField{Path: []string{"clusterName"}}, "userName": &informer.JSONPathField{Path: []string{"userName"}}, "userPrincipalName": &informer.JSONPathField{Path: []string{"userPrincipalName"}}, }, gvkKey("management.cattle.io", "v3", "GlobalRoleBinding"): { "userName": &informer.JSONPathField{Path: []string{"userName"}}, "userPrincipalName": &informer.JSONPathField{Path: []string{"userPrincipalName"}}, }, gvkKey("management.cattle.io", "v3", "Node"): { "status.nodeName": &informer.JSONPathField{Path: []string{"status", "nodeName"}}, }, gvkKey("management.cattle.io", "v3", "NodePool"): { "spec.clusterName": &informer.JSONPathField{Path: []string{"spec", "clusterName"}}, }, gvkKey("management.cattle.io", "v3", "NodeTemplate"): { "spec.clusterName": &informer.JSONPathField{Path: []string{"spec", "clusterName"}}, }, gvkKey("management.cattle.io", "v3", "Project"): { "spec.clusterName": &informer.JSONPathField{Path: []string{"spec", "clusterName"}}, "spec.displayName": &informer.JSONPathField{Path: []string{"spec", "displayName"}}, }, gvkKey("management.cattle.io", "v3", "ProjectRoleTemplateBinding"): { "userName": &informer.JSONPathField{Path: []string{"userName"}}, "userPrincipalName": &informer.JSONPathField{Path: []string{"userPrincipalName"}}, }, gvkKey("management.cattle.io", "v3", "RoleTemplate"): { "context": &informer.JSONPathField{Path: []string{"context"}}, }, gvkKey("management.cattle.io", "v3", "User"): { "principalIds": &informer.JSONPathField{Path: []string{"principalIds"}}, }, gvkKey("networking.k8s.io", "v1", "Ingress"): { "spec.rules.host": &informer.JSONPathField{Path: []string{"spec", "rules", "host"}}, "spec.ingressClassName": &informer.JSONPathField{Path: []string{"spec", "ingressClassName"}}, }, gvkKey("provisioning.cattle.io", "v1", "Cluster"): { "metadata.annotations[provisioning.cattle.io/management-cluster-display-name]": &informer.JSONPathField{Path: []string{"metadata", "annotations", "provisioning.cattle.io/management-cluster-display-name"}}, "status.allocatable.cpu": &informer.JSONPathField{Path: []string{"status", "allocatable", "cpu"}}, "status.allocatable.cpuRaw": &informer.JSONPathField{Type: "REAL", Path: []string{"status", "allocatable", "cpuRaw"}}, "status.allocatable.memory": &informer.JSONPathField{Path: []string{"status", "allocatable", "memory"}}, "status.allocatable.memoryRaw": &informer.JSONPathField{Type: "REAL", Path: []string{"status", "allocatable", "memoryRaw"}}, "status.allocatable.pods": &informer.JSONPathField{Type: "INT", Path: []string{"status", "allocatable", "pods"}}, "status.clusterName": &informer.JSONPathField{Path: []string{"status", "clusterName"}}, "status.provider": &informer.JSONPathField{Path: []string{"status", "provider"}}, "status.requested.cpu": &informer.JSONPathField{Path: []string{"status", "requested", "cpu"}}, "status.requested.cpuRaw": &informer.JSONPathField{Type: "REAL", Path: []string{"status", "requested", "cpuRaw"}}, "status.requested.memory": &informer.JSONPathField{Path: []string{"status", "requested", "memory"}}, "status.requested.memoryRaw": &informer.JSONPathField{Type: "REAL", Path: []string{"status", "requested", "memoryRaw"}}, "status.requested.pods": &informer.JSONPathField{Type: "INT", Path: []string{"status", "requested", "pods"}}, }, gvkKey("rke.cattle.io", "v1", "ETCDSnapshot"): { "snapshotFile.createdAt": &informer.JSONPathField{Path: []string{"snapshotFile", "createdAt"}}, "spec.clusterName": &informer.JSONPathField{Path: []string{"spec", "clusterName"}}, }, gvkKey("storage.k8s.io", "v1", "StorageClass"): { "provisioner": &informer.JSONPathField{Path: []string{"provisioner"}}, "metadata.annotations[storageclass.kubernetes.io/is-default-class]": &informer.JSONPathField{Path: []string{"metadata", "annotations", "storageclass.kubernetes.io/is-default-class"}}, }, } )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// AugmentList takes a list of resources, and for some of them,
// adds related data to each item in the list
AugmentList(ctx context.Context, list *unstructured.UnstructuredList, childGVK schema.GroupVersionKind, childSchemaName string, useSelectors bool, accessList accesscontrol.AccessListByVerb) error
// ListByOptions returns objects according to the specified list options and partitions.
// Specifically:
// - an unstructured list of resources belonging to any of the specified partitions
// - the total number of resources (returned list might be a subset depending on pagination options in lo)
// - a summary object, containing the possible values for each field specified in a summary= subquery
// - a continue token, if there are more pages after the returned one
// - an error instead of all of the above if anything went wrong
ListByOptions(ctx context.Context, lo *sqltypes.ListOptions, partitions []partition.Partition, namespace string) (*unstructured.UnstructuredList, int, *types.APISummary, string, error)
}
type CacheFactory ¶
type CacheFactory interface {
CacheFor(ctx context.Context, fields map[string]informer.IndexedField, externalUpdateInfo *sqltypes.ExternalGVKUpdates, selfUpdateInfo *sqltypes.ExternalGVKUpdates, transform cache.TransformFunc, client dynamic.ResourceInterface, gvk schema.GroupVersionKind, namespaced bool, watchable bool) (*factory.Cache, error)
DoneWithCache(*factory.Cache)
Stop(gvk schema.GroupVersionKind) error
}
type CacheFactoryInitializer ¶
type CacheFactoryInitializer func() (CacheFactory, error)
type ClientGetter ¶
type ClientGetter interface {
IsImpersonating() bool
K8sInterface(ctx *types.APIRequest) (kubernetes.Interface, error)
AdminK8sInterface() (kubernetes.Interface, error)
Client(ctx *types.APIRequest, schema *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
DynamicClient(ctx *types.APIRequest, warningHandler rest.WarningHandler) (dynamic.Interface, error)
AdminClient(ctx *types.APIRequest, schema *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
TableClient(ctx *types.APIRequest, schema *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
TableAdminClient(ctx *types.APIRequest, schema *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
TableClientForWatch(ctx *types.APIRequest, schema *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
TableAdminClientForWatch(ctx *types.APIRequest, schema *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
}
ClientGetter is a dynamic kubernetes client factory.
type RelationshipNotifier ¶
type RelationshipNotifier interface {
OnInboundRelationshipChange(ctx context.Context, schema *types.APISchema, namespace string) <-chan *summary.Relationship
}
RelationshipNotifier is an interface for handling wrangler summary.Relationship events.
type SchemaCollection ¶ added in v0.7.39
type SchemaColumnSetter ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func NewProxyStore ¶
func NewProxyStore(ctx context.Context, c SchemaColumnSetter, clientGetter ClientGetter, notifier RelationshipNotifier, scache virtualCommon.SummaryCache, schemas SchemaCollection, factory CacheFactory, needToInitNamespaceCache bool) (*Store, error)
NewProxyStore returns a Store implemented directly on top of kubernetes.
func (*Store) AugmentRelationships ¶ added in v0.8.19
func (s *Store) AugmentRelationships(ctx context.Context, gvk schema.GroupVersionKind, list *unstructured.UnstructuredList, apiOp *types.APIRequest) error
func (*Store) ByID ¶
func (s *Store) ByID(apiOp *types.APIRequest, schema *types.APISchema, id string) (*unstructured.Unstructured, []types.Warning, error)
ByID looks up a single object by its ID.
func (*Store) Create ¶
func (s *Store) Create(apiOp *types.APIRequest, schema *types.APISchema, params types.APIObject) (*unstructured.Unstructured, []types.Warning, error)
Create creates a single object in the store.
func (*Store) Delete ¶
func (s *Store) Delete(apiOp *types.APIRequest, schema *types.APISchema, id string) (*unstructured.Unstructured, []types.Warning, error)
Delete deletes an object from a store.
func (*Store) ListByPartitions ¶
func (s *Store) ListByPartitions(apiOp *types.APIRequest, apiSchema *types.APISchema, partitions []partition.Partition) (list *unstructured.UnstructuredList, total int, summary *types.APISummary, continueToken string, err error)
ListByPartitions returns:
- an unstructured list of resources belonging to any of the specified partitions
- the total number of resources (returned list might be a subset depending on pagination options in apiOp)
- a summary object, containing the possible values for each field specified in a summary= subquery
- a continue token, if there are more pages after the returned one
- an error instead of all of the above if anything went wrong
func (*Store) Reset ¶
func (s *Store) Reset(gvk schema.GroupVersionKind) error
Reset locks the store, resets the underlying cache factory, and warm the namespace cache.
func (*Store) Update ¶
func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params types.APIObject, id string) (*unstructured.Unstructured, []types.Warning, error)
Update updates a single object in the store.
func (*Store) Watch ¶
func (s *Store) Watch(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest) (chan watch.Event, error)
Watch returns a channel of events for a list or resource.
func (*Store) WatchByPartitions ¶
func (s *Store) WatchByPartitions(apiOp *types.APIRequest, schema *types.APISchema, wr types.WatchRequest, partitions []partition.Partition) (chan watch.Event, error)
WatchByPartitions returns a channel of events for a list or resource belonging to any of the specified partitions
func (*Store) WatchNames ¶
func (s *Store) WatchNames(apiOp *types.APIRequest, schema *types.APISchema, w types.WatchRequest, names sets.Set[string]) (chan watch.Event, error)
WatchNames returns a channel of events filtered by an allowed set of names. In plain kubernetes, if a user has permission to 'list' or 'watch' a defined set of resource names, performing the list or watch will result in a Forbidden error, because the user does not have permission to list *all* resources. With this filter, the request can be performed successfully, and only the allowed resources will be returned in watch.
type TransformBuilder ¶
type TransformBuilder interface {
GetTransformFunc(gvk schema.GroupVersionKind, colDefs []common.ColumnDefinition, isCRD bool, jsonPaths map[string]*jsonpath.JSONPath) cache.TransformFunc
}
type WarningBuffer ¶
WarningBuffer holds warnings that may be returned from the kubernetes api
func (*WarningBuffer) HandleWarningHeader ¶
func (w *WarningBuffer) HandleWarningHeader(code int, agent string, text string)
HandleWarningHeader takes the components of a kubernetes warning header and stores them
Directories
¶
| Path | Synopsis |
|---|---|
|
Package tablelistconvert provides a client that will use a table client but convert *UnstructuredList and *Unstructured objects returned by ByID and List to resemble those returned by non-table clients while preserving some table-related data.
|
Package tablelistconvert provides a client that will use a table client but convert *UnstructuredList and *Unstructured objects returned by ByID and List to resemble those returned by non-table clients while preserving some table-related data. |