git

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MPL-2.0 Imports: 23 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.

Documentation

Overview

Package git implements a state backend that keeps encrypted state on a dedicated branch of a Git repository, for small projects that don't want to set up any cloud storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New creates a new backend that stores state in a Git repository.

Types

type Backend

type Backend struct {
	*schema.Backend
	// contains filtered or unexported fields
}

Backend stores state on a branch of a Git repository.

func (*Backend) DeleteWorkspace

func (b *Backend) DeleteWorkspace(ctx context.Context, name string, _ bool) error

DeleteWorkspace removes a workspace's state from the branch. Earlier versions stay in Git's history.

func (*Backend) StateMgr

func (b *Backend) StateMgr(ctx context.Context, name string) (statemgr.Full, error)

StateMgr returns the state manager for a workspace, creating an empty state if it's new.

func (*Backend) StateVersionData

func (b *Backend) StateVersionData(ctx context.Context, workspace, id string) ([]byte, error)

StateVersionData returns the workspace's state as it was at a commit on the state branch. The commit must be on the branch, so that a commit from elsewhere in the repository can't be passed off as state.

func (*Backend) StateVersions

func (b *Backend) StateVersions(ctx context.Context, workspace string, limit int) ([]backend.StateVersion, error)

StateVersions lists the commits on the state branch that changed the workspace's state.

func (*Backend) Workspaces

func (b *Backend) Workspaces(ctx context.Context) ([]string, error)

Workspaces lists the workspaces that have state on the branch.

type Client

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

Client reads and writes one workspace's state.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context) error

Delete removes the state from the branch.

func (*Client) Get

func (c *Client) Get(ctx context.Context) (*remote.Payload, error)

Get returns the current state, or nil if there isn't any.

func (*Client) Lock

func (c *Client) Lock(ctx context.Context, info *statemgr.LockInfo) (string, error)

Lock acquires the lock by creating a branch. Git only accepts the push if the branch doesn't exist yet, so exactly one of any number of concurrent runs succeeds.

func (*Client) Put

func (c *Client) Put(ctx context.Context, data []byte) error

Put writes the state. State can hold secrets and Git keeps every version forever, so unencrypted state is refused unless the configuration explicitly allows it.

func (*Client) Unlock

func (c *Client) Unlock(ctx context.Context, id string) error

Unlock releases the lock if the ID matches. Deleting with a lease means a lock taken over by someone else in the meantime isn't removed by mistake.

Jump to

Keyboard shortcuts

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