deploymentlease

package
v0.133.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 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.

README

Deployment authority lease client

deploymentlease.Client is the shared mTLS client for the Fleet Deployment Authority. It uses the maintained go-common/spiffe Workload API adapter, checks the authority's exact SPIFFE server identity, verifies the returned DSSE authorization against caller-supplied protected Ed25519 keys, and then acquires a lease bound to the same intent, principal, attempt, policy, and logical target.

Load signing keys from protected runtime configuration and keep them outside the public service catalog and task input. Use an HTTPS endpoint reachable on the private service network. The SPIFFE HTTP transport does not use HTTP proxy environment variables and does not follow redirects. The authority client's default transport deadline is 160 seconds because CI, approval, and provenance checks are bounded at the server but may exceed a normal service-to-service request timeout. Callers should still provide a shorter context deadline for lease actions; the transport itself is capped at three minutes.

Acquisition retries must reuse the same attempt ID. The authority makes those requests idempotent. Call Validate immediately before each deployment mutation, renew before the lease is near expiry, and call Finish with the verified outcome. If the process exits before Finish, the bounded lease expiry releases the reservation.

The fencing number is monotonic, but this package alone cannot enforce it at a runtime host. An execution adapter must reject stale fences at the mutation boundary; a client-side check is not a substitute for target-side fencing. Until that adapter is deployed and verified, treat this client as a control plane building block rather than proof that a runtime mutation is fenced.

Documentation

Overview

Package deploymentlease is the shared fail-closed client for the Fleet Deployment Authority's mTLS authorization and target-lease API.

Index

Constants

View Source
const (
	MinLifetime = 30 * time.Second
	MaxLifetime = 10 * time.Minute
)

Variables

View Source
var (
	ErrInvalidConfig = errors.New("deployment authority client configuration is invalid")
	ErrUnavailable   = errors.New("deployment authority is unavailable")
	ErrRejected      = errors.New("deployment authorization or lease was rejected")
	ErrInvalidLease  = errors.New("deployment authority returned an invalid lease")
)

Functions

This section is empty.

Types

type Client

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

func New

func New(ctx context.Context, cfg Config) (*Client, error)

New creates a redirect-disabled mTLS client from the local SPIFFE Workload API. Proxy environment variables are ignored by go-common/spiffe.

func (*Client) Acquire

func (c *Client) Acquire(ctx context.Context, intent deploymentintent.V1, attemptID, targetID string) (Lease, error)

Acquire first asks the authority to evaluate the immutable intent, verifies the returned DSSE allow with protected keys, then reserves an exact logical target. Retries are safe only when callers reuse the same attemptID.

func (*Client) Close

func (c *Client) Close() error

func (*Client) Finish

func (c *Client) Finish(ctx context.Context, lease Lease, outcome string) error

Finish releases the lease after a completed deployment or a verified rollback/failure outcome. Expiry remains the bounded recovery path if the runner is terminated before it can report completion.

func (*Client) IssueRegistryCredential

func (c *Client) IssueRegistryCredential(ctx context.Context, lease Lease) (RegistryCredential, error)

IssueRegistryCredential asks the authority for a short-lived, repository- scoped read-only image-pull token. The authority refuses issuance without a currently active lease owned by this mTLS principal.

func (*Client) Renew

func (c *Client) Renew(ctx context.Context, lease Lease, lifetime time.Duration) (Lease, error)

Renew extends a current lease, up to the authority's ten-minute maximum.

func (*Client) RevokeRegistryCredential

func (c *Client) RevokeRegistryCredential(ctx context.Context, lease Lease, credentialID string) error

RevokeRegistryCredential invalidates the bearer token immediately after the image has been pulled. A bounded provider expiry remains the crash fallback.

func (*Client) Validate

func (c *Client) Validate(ctx context.Context, lease Lease) (Lease, error)

Validate checks current ownership, fence, policy, and expiry at the authority. Call it immediately before each runtime mutation.

type Config

type Config struct {
	Endpoint          string
	WorkloadAPISocket string
	ServerSPIFFEIDs   []string
	Principal         string
	SigningKeys       map[string]ed25519.PublicKey
	RequestTimeout    time.Duration
}

Config uses only private runtime configuration. Keys must be loaded from a protected file by the caller; public intent/evidence never supplies trust roots. ServerSPIFFEIDs is an exact peer allowlist.

type Lease

type Lease struct {
	LeaseID         string    `json:"lease_id"`
	DecisionID      string    `json:"decision_id"`
	AttemptID       string    `json:"attempt_id"`
	IntentID        string    `json:"intent_id"`
	IntentDigest    string    `json:"intent_digest"`
	ArtifactDigest  string    `json:"artifact_digest"`
	SourceCommit    string    `json:"source_commit"`
	RollbackDigest  string    `json:"rollback_digest"`
	Principal       string    `json:"principal"`
	ServiceID       string    `json:"service_id"`
	Environment     string    `json:"environment"`
	TargetPool      string    `json:"target_pool"`
	TargetID        string    `json:"target_id"`
	PolicyVersion   string    `json:"policy_version"`
	Fence           int64     `json:"fence"`
	State           string    `json:"state"`
	IssuedAt        time.Time `json:"issued_at"`
	ExpiresAt       time.Time `json:"expires_at"`
	IntentExpiresAt time.Time `json:"intent_expires_at"`
}

Lease is the durable authority's active reservation. Fence is monotonically increasing for a service/target pair and must be checked before each runtime mutation by the execution layer.

type RegistryCredential

type RegistryCredential struct {
	CredentialID string    `json:"credential_id"`
	Token        []byte    `json:"-"`
	ExpiresAt    time.Time `json:"expires_at"`
}

RegistryCredential is a single-repository, read-only pull token issued only for an active deployment lease. Token is held as bytes so callers can clear it as soon as the image pull finishes. String formatting always redacts it.

func (*RegistryCredential) Clear

func (c *RegistryCredential) Clear()

Clear zeroes the in-memory bearer token after use.

func (RegistryCredential) GoString

func (c RegistryCredential) GoString() string

func (RegistryCredential) String

func (c RegistryCredential) String() string

func (*RegistryCredential) UnmarshalJSON

func (c *RegistryCredential) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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