Documentation
¶
Overview ¶
Package csi is gitd's Kubernetes CSI node plugin: a pod asks for a workspace like any volume — an ephemeral inline volume of the driver gitd.dev — and gets a copy-on-write checkout, made by the gitd on its node, with no credential in the pod.
The plugin asks gitd for a workspace that carries its pool inside it (pool_inside), mounts the pool's objects read-only at the workspace's .git/gitd-pool, and binds the workspace onto the pod's volume. When the pod goes it unmounts both and gitd removes the workspace. CSI node plugins are privileged by design: that is where the privilege to mount belongs, not in gitd, nor in the pod.
Index ¶
- Constants
- func Ready(tenants map[string]Tenant) func(context.Context) error
- func Serve(ctx context.Context, path string, identity *Identity, node *Node) error
- func TenantsOf(socket, root string, given []string) (map[string]Tenant, error)
- type Asked
- type Identity
- func (identity *Identity) GetPluginCapabilities(context.Context, *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error)
- func (identity *Identity) GetPluginInfo(context.Context, *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error)
- func (identity *Identity) Probe(ctx context.Context, _ *csi.ProbeRequest) (*csi.ProbeResponse, error)
- type Node
- func (node *Node) NodeGetCapabilities(context.Context, *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error)
- func (node *Node) NodeGetInfo(context.Context, *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error)
- func (node *Node) NodePublishVolume(ctx context.Context, request *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error)
- func (node *Node) NodeUnpublishVolume(ctx context.Context, request *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error)
- type Records
- type Tenant
- type Workspaces
Constants ¶
const DriverName = "gitd.dev"
DriverName is the name pods ask for: `csi: { driver: gitd.dev }`.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Asked ¶
type Asked struct {
Repository string
Branch string
Commit string
Tenant string
// Name tells apart two gitd volumes of one pod.
Name string
Namespace string
Pod string
}
Asked is what a pod's volume asks for, from its volume attributes.
type Identity ¶
type Identity struct {
csi.UnimplementedIdentityServer
Version string
// Ready says whether gitd answers.
Ready func(context.Context) error
}
Identity answers who the plugin is, and whether the gitd it needs answers.
func (*Identity) GetPluginCapabilities ¶
func (identity *Identity) GetPluginCapabilities(context.Context, *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error)
GetPluginCapabilities offers nothing beyond a node plugin: no controller, no topology.
func (*Identity) GetPluginInfo ¶
func (identity *Identity) GetPluginInfo(context.Context, *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error)
GetPluginInfo names the driver.
func (*Identity) Probe ¶
func (identity *Identity) Probe(ctx context.Context, _ *csi.ProbeRequest) (*csi.ProbeResponse, error)
Probe says the plugin is ready once gitd answers.
type Node ¶
type Node struct {
csi.UnimplementedNodeServer
NodeID string
Tenants map[string]Tenant
Records Records
}
Node is the plugin's node service: it publishes an ephemeral volume as a workspace of the gitd on its node, and unpublishes it.
func (*Node) NodeGetCapabilities ¶
func (node *Node) NodeGetCapabilities(context.Context, *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error)
NodeGetCapabilities offers nothing beyond publishing: no staging, no stats, no expansion.
func (*Node) NodeGetInfo ¶
func (node *Node) NodeGetInfo(context.Context, *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error)
NodeGetInfo names the node.
func (*Node) NodePublishVolume ¶
func (node *Node) NodePublishVolume(ctx context.Context, request *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error)
NodePublishVolume makes the pod's workspace and mounts it at the volume's target: gitd makes it carrying its pool, the pool's objects are mounted read-only inside it, and the workspace is bound onto the target. Publishing a volume already published changes nothing.
func (*Node) NodeUnpublishVolume ¶
func (node *Node) NodeUnpublishVolume(ctx context.Context, request *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error)
NodeUnpublishVolume unmounts the volume and has gitd remove its workspace.
type Records ¶
type Records struct {
Dir string
}
Records are the volumes the plugin published, one file each under Dir.
type Tenant ¶
type Tenant struct {
Root string
Workspaces Workspaces
}
Tenant is one tenant's gitd as the plugin reaches it, and the root its workspaces are made in; the implicit tenant, when gitd has none, is named "".
type Workspaces ¶
type Workspaces interface {
Prepare(ctx context.Context, request *gitdv1.PrepareRequest) (*gitdv1.WorkspaceResult, error)
Remove(ctx context.Context, path string) error
}
Workspaces are what the plugin needs of gitd, for one tenant: making a workspace and removing it.