carry

package
v0.205.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 13 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 carry brings what the computer the user works on already has for git — its Git name and email, its GitHub CLI's and GitLab CLI's sign-ins — to a computer linked to it, and makes an SSH key there for git (ADR-113, .ai/26-server.md § Bringing sign-ins).

Two halves, one per side of the link:

  • On the laptop, Offer says what there is to bring, read from files, no token's content (readiness.GitIdentity, GHSignedIn, GLabHosts); Read reads one item's values for one send, running `gh auth token` or `glab config get token` only then.
  • On the linked computer, Apply sets an item that arrived — `git config --global`, `gh auth login --with-token` and `gh auth setup-git`, `glab auth login --stdin` — the token on the program's standard input, never in its arguments, a file or a terminal; Remove signs one out there again.

A token is held in memory for the one request it travels in, inside the end-to-end encrypted channel to the user's own computer (ADR-058, ADR-067). It is in no answer, log line, event, file or terminal on either side: errors are redacted before they leave this package.

Index

Constants

View Source
const (
	WhatGit    = "git"
	WhatGitHub = "github"
	WhatGitLab = "gitlab"
	// WhatSSHKey makes an Ed25519 key there and adds it to the forges
	// signed in there; nothing of the laptop's travels with it.
	WhatSSHKey = "ssh_key"
)

What names one item.

View Source
const GitHubHost = "github.com"

GitHubHost is the only GitHub host carried: the checklist's GitHub row is github.com's.

Variables

View Source
var ErrNothing = errors.New("this computer has nothing to bring for that")

ErrNothing is an item this computer does not have to bring.

Functions

This section is empty.

Types

type Env

type Env struct {
	GOOS   string
	Home   string
	Getenv func(string) string
	Run    Runner
	// Hostname names this computer in an SSH key's comment and title.
	Hostname string
}

Env is one side's view: where its files are, and how it runs programs.

func (Env) Apply

func (e Env) Apply(ctx context.Context, p Payload) (Result, error)

Apply sets one item that arrived, on this computer.

func (Env) Offer

func (e Env) Offer() Offer

Offer reads what there is to bring, from files only.

func (Env) Read

func (e Env) Read(ctx context.Context, what, host string) (Payload, error)

Read reads one item's values on this computer, for one send: the Git identity from its files, a GitHub or GitLab token from that CLI. host picks a GitLab host, and must be one Offer lists.

func (Env) Remove

func (e Env) Remove(ctx context.Context, what, host string) error

Remove signs one forge's CLI out here again: the laptop's *Remove from <name>*. host picks a GitLab host.

type Identity

type Identity struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

Identity is a Git name and email. Not a secret: the screen shows it before and after it is set.

type Ledger

type Ledger struct {
	Path string
	// contains filtered or unexported fields
}

Ledger is carried.json in the data directory: per computer id, what was brought there.

func (*Ledger) For

func (l *Ledger) For(id string) []Sent

For is what was brought to computer id.

func (*Ledger) Put

func (l *Ledger) Put(id string, s Sent) error

Put replaces id's entry for s.What and s.Host with s.

type Offer

type Offer struct {
	Git    *Identity             `json:"git,omitempty"`
	GitHub *readiness.ForgeHost  `json:"github,omitempty"`
	GitLab []readiness.ForgeHost `json:"gitlab"`
}

Offer is what this computer can bring to another one. Never a token.

type Payload

type Payload struct {
	What  string `json:"what"`
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
	Host  string `json:"host,omitempty"`
	User  string `json:"user,omitempty"`
	Token string `json:"token,omitempty"`
}

Payload is one item in flight: what, and its values. Only ever inside the channel; Token is never logged, answered or written.

type Result

type Result struct {
	What string `json:"what"`
	// Detail is one line: "Ada <ada@example.com>", "signed in as octo".
	Detail string `json:"detail"`
	// Added and Refused are the forges an SSH key was added to, and those
	// that refused it (a token without the scope), each with why.
	Added   []string `json:"added,omitempty"`
	Refused []string `json:"refused,omitempty"`
}

Result is what Apply did there, in words the laptop shows. Never a token.

type Runner

type Runner func(ctx context.Context, stdin, name string, args ...string) (string, error)

Runner runs a program with stdin as its standard input and answers its standard output; a failure carries what it printed on standard error. The daemon's runs the login shell's PATH; tests swap it, so no test runs a real gh, glab, git or ssh-keygen.

type Sent

type Sent struct {
	What   string `json:"what"`
	Host   string `json:"host,omitempty"`
	Detail string `json:"detail"`
	At     int64  `json:"at"`
	// Removed is when *Remove from <name>* signed it out there; an item
	// removed is never brought again by itself.
	Removed int64 `json:"removed,omitempty"`
	// Error is the last automatic try's failure, so it is not tried again
	// on every page open; a click tries again.
	Error string `json:"error,omitempty"`
}

Sent is one item brought to a computer, as the laptop keeps it: what, for which host, the line the computer answered, when, and whether it was removed there since. Never a token.

func Find

func Find(list []Sent, what, host string) (Sent, bool)

Find is the entry for what and host at id, if any.

Jump to

Keyboard shortcuts

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