Documentation
¶
Overview ¶
Package localstate stores runner identity, registrations, and workspace locks outside source repositories.
Index ¶
- func CanonicalWorkspace(path string) (string, error)
- type Credential
- type HostIdentity
- type LockHeldError
- type LockMetadata
- type PendingEnrollment
- type Registration
- type Store
- func (s *Store) AcquireWorkspaceLock(workspace string, metadata LockMetadata) (*WorkspaceLock, error)
- func (s *Store) CommitApprovedEnrollment(expectedEnrollmentID string, credential Credential, registration Registration) (bool, error)
- func (s *Store) DeleteAuthenticationStateForRegistration(server, workspace, expectedRunnerID string) (bool, error)
- func (s *Store) DeleteCredential(server, workspace string) (bool, error)
- func (s *Store) DeletePendingEnrollment(server, workspace string) (bool, error)
- func (s *Store) DeletePendingEnrollmentIfID(server, workspace, expectedEnrollmentID string) (bool, error)
- func (s *Store) DeleteRegistration(server, workspace, expectedRunnerID string) (bool, error)
- func (s *Store) LoadCredential(server, workspace string) (Credential, bool, error)
- func (s *Store) LoadOrCreateHostIdentity() (HostIdentity, error)
- func (s *Store) LoadOrCreatePendingEnrollment(server, workspace string, create func(bool) (PendingEnrollment, error)) (PendingEnrollment, bool, error)
- func (s *Store) LoadPendingEnrollment(server, workspace string) (PendingEnrollment, bool, error)
- func (s *Store) LoadRegistration(server, workspace string) (Registration, bool, error)
- func (s *Store) ReadWorkspaceLockMetadata(workspace string) (LockMetadata, bool, error)
- func (s *Store) Registrations() ([]Registration, error)
- func (s *Store) Root() string
- func (s *Store) SaveCredential(credential Credential) error
- func (s *Store) SavePendingEnrollment(enrollment PendingEnrollment) error
- func (s *Store) SaveRegistration(registration Registration) error
- func (s *Store) WorkspaceLockHeld(workspace string) (bool, error)
- func (s *Store) WorkspaceLockPath(workspace string) string
- type WorkspaceLock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalWorkspace ¶
CanonicalWorkspace resolves an existing workspace to a stable absolute path.
Types ¶
type Credential ¶
type Credential struct {
Version int `json:"version"`
Server string `json:"server"`
Workspace string `json:"workspace"`
CredentialID string `json:"credentialId"`
AccessToken string `json:"-"`
Fingerprint string `json:"fingerprint"`
PublicKey ed25519.PublicKey `json:"-"`
PrivateKey ed25519.PrivateKey `json:"-"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Credential is one active server-issued credential bound to a runner-local Ed25519 key pair. PrivateKey and PublicKey are encoded as unpadded base64url only in the on-disk representation.
type HostIdentity ¶
type HostIdentity struct {
Version int `json:"version"`
InstanceID string `json:"instanceId"`
CreatedAt time.Time `json:"createdAt"`
}
HostIdentity is the stable, non-secret identifier for one local Kodelet installation.
func LoadDefaultHostIdentity ¶
func LoadDefaultHostIdentity() (HostIdentity, error)
LoadDefaultHostIdentity reads an existing installation identity without creating runner state or acquiring workspace locks. Thin clients use it only to compare the daemon's advertised embedded host, never to infer locality from a URL.
type LockHeldError ¶
type LockHeldError struct {
Path string
Metadata LockMetadata
}
LockHeldError reports diagnostics from an already-running workspace runner.
func (*LockHeldError) Error ¶
func (e *LockHeldError) Error() string
type LockMetadata ¶
type LockMetadata struct {
Version int `json:"version"`
PID int `json:"pid"`
Hostname string `json:"hostname"`
Workspace string `json:"workspace"`
Server string `json:"server"`
RunnerID string `json:"runnerId,omitempty"`
DisplayName string `json:"displayName,omitempty"`
StartedAt time.Time `json:"startedAt"`
StoppedAt *time.Time `json:"stoppedAt,omitempty"`
}
LockMetadata is diagnostic process information stored in the advisory lock file.
type PendingEnrollment ¶
type PendingEnrollment struct {
Version int `json:"version"`
Server string `json:"server"`
Workspace string `json:"workspace"`
EnrollmentID string `json:"enrollmentId"`
DeviceCode string `json:"deviceCode"`
UserCode string `json:"userCode,omitempty"`
VerificationURL string `json:"verificationUrl,omitempty"`
VerificationURLComplete string `json:"verificationUrlComplete,omitempty"`
Fingerprint string `json:"fingerprint"`
PublicKey ed25519.PublicKey `json:"-"`
PrivateKey ed25519.PrivateKey `json:"-"`
ExpiresAt time.Time `json:"expiresAt"`
PollIntervalMS int64 `json:"pollIntervalMs,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
PendingEnrollment is one unapproved device-enrollment flow and its runner-local key pair.
type Registration ¶
type Registration struct {
Version int `json:"version"`
Server string `json:"server"`
Workspace string `json:"workspace"`
RunnerID string `json:"runnerId"`
DisplayName string `json:"displayName,omitempty"`
UpdatedAt time.Time `json:"updatedAt"`
}
Registration caches one control-plane-assigned runner identity for a host workspace.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store owns runner-local state rooted below the Kodelet user-state directory.
func NewStoreAt ¶
NewStoreAt opens a runner-local state directory at an explicit path.
func (*Store) AcquireWorkspaceLock ¶
func (s *Store) AcquireWorkspaceLock(workspace string, metadata LockMetadata) (*WorkspaceLock, error)
AcquireWorkspaceLock acquires the non-blocking advisory lock for a canonical workspace.
func (*Store) CommitApprovedEnrollment ¶
func (s *Store) CommitApprovedEnrollment(expectedEnrollmentID string, credential Credential, registration Registration) (bool, error)
CommitApprovedEnrollment saves approved state only if the pending enrollment still matches.
func (*Store) DeleteAuthenticationStateForRegistration ¶
func (s *Store) DeleteAuthenticationStateForRegistration(server, workspace, expectedRunnerID string) (bool, error)
DeleteAuthenticationStateForRegistration removes local authentication state only while the cached registration still names the expected runner.
func (*Store) DeleteCredential ¶
DeleteCredential atomically removes the active credential for a server and canonical workspace.
func (*Store) DeletePendingEnrollment ¶
DeletePendingEnrollment atomically removes the pending enrollment for a server and canonical workspace.
func (*Store) DeletePendingEnrollmentIfID ¶
func (s *Store) DeletePendingEnrollmentIfID(server, workspace, expectedEnrollmentID string) (bool, error)
DeletePendingEnrollmentIfID removes pending state only if its enrollment ID still matches.
func (*Store) DeleteRegistration ¶
DeleteRegistration removes a cached registration only when it still contains the expected runner ID.
func (*Store) LoadCredential ¶
func (s *Store) LoadCredential(server, workspace string) (Credential, bool, error)
LoadCredential returns the active key-bound credential for a server and canonical workspace.
func (*Store) LoadOrCreateHostIdentity ¶
func (s *Store) LoadOrCreateHostIdentity() (HostIdentity, error)
LoadOrCreateHostIdentity returns the stable host instance ID, creating it atomically when absent.
func (*Store) LoadOrCreatePendingEnrollment ¶
func (s *Store) LoadOrCreatePendingEnrollment(server, workspace string, create func(bool) (PendingEnrollment, error)) (PendingEnrollment, bool, error)
LoadOrCreatePendingEnrollment serializes enrollment creation for one server and workspace. The create callback runs while the cross-process state lock is held and receives whether an active credential currently exists.
func (*Store) LoadPendingEnrollment ¶
func (s *Store) LoadPendingEnrollment(server, workspace string) (PendingEnrollment, bool, error)
LoadPendingEnrollment returns the pending enrollment for a server and canonical workspace.
func (*Store) LoadRegistration ¶
func (s *Store) LoadRegistration(server, workspace string) (Registration, bool, error)
LoadRegistration returns a cached stable runner ID for a server and canonical workspace.
func (*Store) ReadWorkspaceLockMetadata ¶
func (s *Store) ReadWorkspaceLockMetadata(workspace string) (LockMetadata, bool, error)
ReadWorkspaceLockMetadata reads the latest diagnostic lock metadata without acquiring the lock.
func (*Store) Registrations ¶
func (s *Store) Registrations() ([]Registration, error)
Registrations lists every locally cached control-plane registration.
func (*Store) SaveCredential ¶
func (s *Store) SaveCredential(credential Credential) error
SaveCredential atomically persists an active key-bound credential.
func (*Store) SavePendingEnrollment ¶
func (s *Store) SavePendingEnrollment(enrollment PendingEnrollment) error
SavePendingEnrollment atomically persists a pending device-enrollment flow.
func (*Store) SaveRegistration ¶
func (s *Store) SaveRegistration(registration Registration) error
SaveRegistration atomically updates a cached stable runner ID.
func (*Store) WorkspaceLockHeld ¶
WorkspaceLockHeld reports whether another open file description currently owns the advisory lock for a workspace. A stale diagnostic file without a live lock returns false.
func (*Store) WorkspaceLockPath ¶
WorkspaceLockPath returns the diagnostic lock-file path for a canonical workspace.
type WorkspaceLock ¶
type WorkspaceLock struct {
// contains filtered or unexported fields
}
WorkspaceLock holds the OS-level advisory lock for one canonical workspace.
func (*WorkspaceLock) Close ¶
func (l *WorkspaceLock) Close() error
Close records a stop time and releases the advisory lock.
func (*WorkspaceLock) Metadata ¶
func (l *WorkspaceLock) Metadata() LockMetadata
Metadata returns the latest metadata written by this process.
func (*WorkspaceLock) Path ¶
func (l *WorkspaceLock) Path() string
Path returns the diagnostic lock-file path.
func (*WorkspaceLock) WriteMetadata ¶
func (l *WorkspaceLock) WriteMetadata(metadata LockMetadata) error
WriteMetadata updates the diagnostic JSON while retaining the advisory lock.