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) 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) GetUsername() string
- func (u *User) HasRole(role models.Role) bool
- func (u *User) ProfileSnapshot() models.UserProfile
- func (u *User) String() string
- func (u *User) SudoEnabled() bool
- func (u *User) UpdateProfile(profile models.UserProfile)
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 a snapshot of User for use in a shell session.
type User ¶
type User struct {
// contains filtered or unexported fields
}
User holds the workspace identity. It is populated once from the user's profile in NewUser. UID, GID, home directory and groups are fixed for the lifetime of the process — they're baked into the OS user created at startup. The rest of the profile can be refreshed from the API server via UpdateProfile (see RESTService.GetProfile), so all profile reads go through a mutex.
func NewUser ¶
func NewUser(profile *models.UserProfile) *User
NewUser creates a User from a resolved profile.
func (*User) GetGroups ¶
GetGroups returns the supplementary groups for the user. TODO: derive from the profile or a policy source once that is implemented.
func (*User) GetHomeDir ¶
GetHomeDir returns the home directory, defaulting to /home/<username> when unset.
func (*User) ProfileSnapshot ¶ added in v0.16.0
func (u *User) ProfileSnapshot() models.UserProfile
ProfileSnapshot returns a copy of the user's profile.
func (*User) SudoEnabled ¶
SudoEnabled returns whether passwordless sudo is enabled for the user.
func (*User) UpdateProfile ¶ added in v0.16.0
func (u *User) UpdateProfile(profile models.UserProfile)
UpdateProfile replaces the user's profile with a freshly fetched copy, typically after a live re-fetch from the API server (see RESTService.GetProfile). UID and GID are preserved from the current profile rather than taken from the argument: they're baked into the OS user created at startup, and every UID/GID-based operation (chown, process credentials) assumes they never change underneath it.