Documentation
¶
Overview ¶
Package models defines shared data types and domain models for k8shelld.
Index ¶
- Variables
- type Group
- type InitScriptState
- type InitScriptStatus
- type InitTracker
- func (t *InitTracker) AllDone() bool
- func (t *InitTracker) GetAll() []InitScriptState
- func (t *InitTracker) HasAny() bool
- func (t *InitTracker) HasPendingOrRunning() bool
- func (t *InitTracker) RegisterAll(names []string)
- func (t *InitTracker) SetCompleted(name string, hasError bool)
- func (t *InitTracker) SetRunning(name string)
- type K8shellFileValidationResponse
- type ShellUser
- type User
- func (u *User) ClaimsSnapshot() authz.UserClaims
- func (u *User) GetGID() uint32
- func (u *User) GetGroups() []Group
- func (u *User) GetHomeDir() string
- func (u *User) GetShell() string
- func (u *User) GetUID() uint32
- func (u *User) GetUserToken() string
- func (u *User) GetUsername() string
- func (u *User) HasRole(role models.Role) bool
- func (u *User) String() string
- func (u *User) SudoEnabled() bool
- func (u *User) TokenEqual(token string) bool
- func (u *User) Update(claims *authz.UserClaims, token string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var RESTAPIUnixSocket = "/var/run/k8shelld.sock"
Functions ¶
This section is empty.
Types ¶
type InitScriptState ¶
type InitScriptState struct {
Name string `json:"name"`
Status InitScriptStatus `json:"status"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
HasError bool `json:"has_error"`
}
InitScriptState holds the observable state of one init script.
type InitScriptStatus ¶
type InitScriptStatus string
InitScriptStatus represents the lifecycle state of an init script.
const ( InitScriptPending InitScriptStatus = "pending" InitScriptRunning InitScriptStatus = "running" InitScriptCompleted InitScriptStatus = "completed" )
type InitTracker ¶
type InitTracker struct {
// contains filtered or unexported fields
}
InitTracker is a thread-safe store for the lifecycle state of all init scripts.
func NewInitTracker ¶
func NewInitTracker() *InitTracker
NewInitTracker returns an empty InitTracker.
func (*InitTracker) AllDone ¶
func (t *InitTracker) AllDone() bool
AllDone reports whether every registered script has reached the completed state.
func (*InitTracker) GetAll ¶
func (t *InitTracker) GetAll() []InitScriptState
GetAll returns a snapshot copy of all script states.
func (*InitTracker) HasAny ¶
func (t *InitTracker) HasAny() bool
HasAny reports whether any scripts have been registered.
func (*InitTracker) HasPendingOrRunning ¶
func (t *InitTracker) HasPendingOrRunning() bool
HasPendingOrRunning reports whether at least one script is still pending or running.
func (*InitTracker) RegisterAll ¶
func (t *InitTracker) RegisterAll(names []string)
RegisterAll pre-populates the tracker with all script names in pending state. This must be called before any goroutine calls SetRunning or SetCompleted.
func (*InitTracker) SetCompleted ¶
func (t *InitTracker) SetCompleted(name string, hasError bool)
SetCompleted marks the named script as completed and records its finish time.
func (*InitTracker) SetRunning ¶
func (t *InitTracker) SetRunning(name string)
SetRunning marks the named script as running and records its start time.
type K8shellFileValidationResponse ¶
type K8shellFileValidationResponse struct {
Status string `json:"status"`
Filename string `json:"filename"`
Errors []string `json:"errors,omitempty"`
}
K8shellFileValidationResponse represents the response for k8shell file validation
type ShellUser ¶
type ShellUser struct {
Username string
UID uint32
GID uint32
HomeDir string
Shell string
Sudo bool
Groups []Group
}
ShellUser is an immutable snapshot of the identity fields needed to launch a shell process. Obtain it via NewShellUser before starting a session; the snapshot is safe to use without further locking for the session's lifetime.
func NewShellUser ¶
NewShellUser takes an atomic snapshot of User for use in a shell session.
type User ¶
type User struct {
// contains filtered or unexported fields
}
User holds the workspace identity.
Immutable fields (username, uid, gid, homeDir, groups) are set once in NewUser and never changed — they may be read from any goroutine without acquiring mu.
Mutable fields (claims, userToken) are replaced atomically on each token renewal and must always be accessed through the accessor methods, which acquire mu internally.
func NewUser ¶
func NewUser(claims *authz.UserClaims, token string) *User
NewUser creates a User from a verified JWT claims set and the raw token string.
func (*User) ClaimsSnapshot ¶
func (u *User) ClaimsSnapshot() authz.UserClaims
ClaimsSnapshot returns a copy of the current JWT claims under the read lock. The returned value is safe to inspect without any further locking.
func (*User) GetGroups ¶
GetGroups returns the supplementary groups for the user. TODO: derive from JWT claims or a policy source once that is implemented.
func (*User) GetHomeDir ¶
GetHomeDir returns the home directory, defaulting to /home/<username> when unset. Immutable — no lock needed.
func (*User) GetUserToken ¶
GetUserToken returns the current raw JWT string.
func (*User) GetUsername ¶
GetUsername returns the username (JWT subject). Immutable — no lock needed.
func (*User) SudoEnabled ¶
SudoEnabled returns whether passwordless sudo is enabled for the user.