attach

package
v0.45.2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package attach is the contract between the node plugin of a repos volume and the control plane that decides which repositories a pod may see: the signed attach request, the answer and the check of the attach grant.

Index

Constants

View Source
const (
	// RequestContext separates the signature of an attach request from every other signature of the node key.
	RequestContext = "motte-attach-request-v1"
	// KidHeader and SignatureHeader carry the key id of the node and the signature (base64url, no padding) over the
	// body of the request.
	KidHeader       = "Motte-Node-Kid"
	SignatureHeader = "Motte-Node-Signature"
	// Window is how far the time of a request may lie from the time of the receiver, in both directions.
	Window = time.Minute
	// GrantLife is the longest life of an attach grant.
	GrantLife = 5 * time.Minute
	// MaxBody is the longest request or answer body.
	MaxBody = 64 << 10
)

Variables

View Source
var ErrRefused = errors.New("attach: not accepted")

ErrRefused is the one error of a request or a grant that is not accepted. It never says why.

Functions

func Sign

func Sign(key *signing.Private, r Request) (body, sig []byte, err error)

Sign returns the body of the request and its signature under RequestContext.

func ValidName

func ValidName(name string) bool

ValidName reports whether name is "owner/name": two parts of 1 to 100 characters of A-Z, a-z, 0-9, dot, dash and underscore, each starting with a letter or a digit.

func VerifyGrant

func VerifyGrant(v *grant.Verifier, token string, b Binding, now time.Time) (grant.Claims, error)

VerifyGrant returns the claims of an attach grant when v accepts it as an attach grant, it names b, and it expires within GrantLife of now.

Types

type Binding

type Binding struct {
	PodUID, VolumeID, Name string
}

Binding is what an attach grant must name to be used.

type Request

type Request struct {
	PodUID    string `json:"pod_uid"`
	VolumeID  string `json:"volume_id"`
	Workspace string `json:"workspace"`
	Name      string `json:"name"`
	TS        int64  `json:"ts"`
	Nonce     string `json:"nonce"`
}

Request is what the node asks. PodUID and VolumeID come from the kubelet at publish; the sandbox cannot choose them. TS is Unix seconds. The receiver checks TS against Window and remembers each accepted Nonce until after TS plus Window, or for two Windows from its first acceptance, and checks and records it in one atomic step across its replicas.

func VerifyRequest

func VerifyRequest(pub signing.Public, body, sig []byte, now time.Time) (Request, error)

VerifyRequest returns the request in body when sig is a signature of pub over body, the request is complete and its time is within Window of now. It does not check the nonce.

type Response

type Response struct {
	Status       Status `json:"status"`
	Grant        string `json:"grant,omitempty"`
	RetryAfterMS int    `json:"retry_after_ms,omitempty"`
}

Response is the body of the answer to a request with the HTTP status 200. Any other HTTP status is a failure of the control plane.

type Status

type Status string

Status is the answer of the control plane.

const (
	// Ready carries the attach grant.
	Ready Status = "ready"
	// Denied means that the principal of the pod may not see the repository, or that the control plane refuses.
	Denied Status = "denied"
	// NotFound means that the repository does not exist.
	NotFound Status = "not_found"
	// Pending means that the control plane prepares the repository and the caller asks again after RetryAfterMS.
	Pending Status = "pending"
)

Jump to

Keyboard shortcuts

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