remote

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 35 Imported by: 1 module, 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

Index

Constants

View Source
const (
	URLEnv      = "ICEBATH_CONFIG_REMOTE_URL"
	InstanceEnv = "ICEBATH_CONFIG_INSTANCE_ID"
)
View Source
const (
	MaxSegments     = 32
	MaxSegmentBytes = 256
	MaxEncodedBytes = 2048
)
View Source
const MaxSafeInteger = 1<<53 - 1

Variables

View Source
var (
	BootRetryDelays = []float64{10, 20}
)
View Source
var PlaneCredentialEnvNames = []string{
	config.BackendEnv, URLEnv, InstanceEnv,
	idpEnvPrefix + "TOKEN_URL", idpEnvPrefix + "CLIENT_ID", idpEnvPrefix + "CLIENT_SECRET", idpEnvPrefix + "SCOPE",
}

Every env name deciding which plane token is sent where, refused from a secret source at boot

Functions

func ApplyIntent

func ApplyIntent(doc map[string]any, sets *PathMap, unsets []Path)

Applies an intent edit to doc in place, an empty mapping set keeping a mapping already there

func BaseURL

func BaseURL() string

Configured plane origin and path prefix with trailing slashes dropped, empty when none is set

func Bearer

func Bearer(ctx context.Context) (string, error)

Plane bearer, resolved only once the plane destination passed the policy

func CheckedURL

func CheckedURL(url, envName string) (string, error)

URL itself when a credential may be sent to it, else a CredentialDestinationError

func Covers

func Covers(lock, path []string) bool

Reports whether a lock is a segment wise prefix of a path

func Diff

func Diff(base, new map[string]any, prefix Path) (*PathMap, []Path)

Sets and unsets turning base into new, a changed list being one whole list set

func DisplayURL

func DisplayURL(url string) string

URL for messages with any user info dropped, an unparsable one cut at the last at sign

func Encode

func Encode(segments []string) string

Wire string of a path, backslash and dot escaped in each segment and segments joined by dots

func EncodeChanges

func EncodeChanges(sets *PathMap, unsets []Path) (*jsonutil.Object, []string)

Wire set object keyed by encoded path and the encoded unset list

func GetRemoteBackend

func GetRemoteBackend() config.ConfigBackend

Process wide remote backend with one poller and one in memory layer per profile home

func InstanceID

func InstanceID() string

func IntentDiff

func IntentDiff(base, new map[string]any, prefix Path) (*PathMap, []Path)

Diff as a key level intent, a non empty mapping the base did not hold as a mapping expanded to its leaves

func IsSecretPath

func IsSecretPath(segments []string) bool

Secret shaped key rule on decoded segments with list indices already dropped

func JSONEqual

func JSONEqual(a, b any) bool

Structural JSON equality with numbers by value and a bool never equal to a number

func PlaneToken

func PlaneToken(ctx context.Context) (string, error)

Fresh bearer from the OAuth2 client credentials grant, an error naming the missing setting when none is configured

func ResetForTests

func ResetForTests()

Stops the poller of the process wide backend and drops it so the next read boots again

func ShownURL

func ShownURL() string

Plane URL without user info for messages, describe and provenance, naming the unset variable when there is none

func ToWire

func ToWire(value any, path Path) (any, error)

Value converted to its JSON wire form, a ConfigValueError naming the path when it has none

func Validate

func Validate(segments []string, encoded *string) error

Segment count, byte length, control character and reserved segment checks of the plane contract

Types

type CredentialDestinationError

type CredentialDestinationError struct{ *PlaneCredentialError }

Credential bound for a destination the transport policy forbids, never retryable

func (*CredentialDestinationError) Unwrap

func (e *CredentialDestinationError) Unwrap() error

type IncompleteRead

type IncompleteRead struct {
	Partial     int
	Expected    int64
	HasExpected bool
}

Body that ended before its declared length, the http.client.IncompleteRead no transport handler catches

func (*IncompleteRead) Error

func (e *IncompleteRead) Error() string

type Lock

type Lock struct {
	Path  Path
	Level string
}

One lock with the level it holds

func CoveringLock

func CoveringLock(locks []Lock, path []string) (Lock, bool)

First lock covering a path, false when none does

func WriteCheck

func WriteCheck(sets *PathMap, unsets []Path, locks []Lock) (Lock, bool)

Lock that refuses this write, false when every lock allows it

type Path

type Path []string

Config plane path as its mapping key segments

func Decode

func Decode(encoded string) (Path, error)

Segments of an encoded path, a PathError for a bad escape, an empty segment or a broken limit

func FromDotted

func FromDotted(dotted string) Path

Path of a dotted key as callers spell it, split on every dot when it does not parse as encoded

func SecretLiteralPath

func SecretLiteralPath(path Path, value any) (Path, bool)

First path under a set of value at path that holds a secret literal, false when none does

func StripLocked

func StripLocked(base, new map[string]any, locks []Lock) (map[string]any, map[string]any, []Path)

Copies of both documents without any locked path, plus the locked paths whose new value differed

type PathError

type PathError struct{ Message string }

Encoded path that does not parse or breaks a segment or length limit

func (*PathError) Error

func (e *PathError) Error() string

type PathMap

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

Insertion ordered map from path to value with Python dict update semantics

func (*PathMap) Entries

func (m *PathMap) Entries() []PathValue

Entries in insertion order

func (*PathMap) Get

func (m *PathMap) Get(p Path) (any, bool)

func (*PathMap) Has

func (m *PathMap) Has(p Path) bool

func (*PathMap) Len

func (m *PathMap) Len() int

func (*PathMap) Set

func (m *PathMap) Set(p Path, v any)

Stores value at p, keeping the position of a path already present

func (*PathMap) SetDefault

func (m *PathMap) SetDefault(p Path, v any)

Stores value at p only when p is absent

type PathValue

type PathValue struct {
	Path  Path
	Value any
}

One path and the value a write sets there

type PlaneCredentialError

type PlaneCredentialError struct {
	Message   string
	Retryable bool
}

No plane credential could be obtained, Retryable false when only a configuration change helps

func (*PlaneCredentialError) Error

func (e *PlaneCredentialError) Error() string

type Response

type Response struct {
	Status        int
	Body          map[string]any
	ETag          string
	RetryAfter    float64
	HasRetryAfter bool
}

One plane answer, HasRetryAfter set when a Retry-After header held a delay in seconds or an HTTP date

func Request

func Request(ctx context.Context, method, profile, etag string, body any, token string) (Response, error)

One call to the self route with token or a bearer resolved here, never following a redirect

func (Response) Error

func (r Response) Error() string

Error code of the body, http_STATUS when the body names none

func (Response) Message

func (r Response) Message() string

Message of the body, HTTP STATUS when the body has none

type TransportError

type TransportError struct{ Message string }

Request that never produced an HTTP response

func (*TransportError) Error

func (e *TransportError) Error() string

Jump to

Keyboard shortcuts

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