hst: reword and improve doc comments
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m9s
Test / Hpkg (push) Successful in 3m58s
Test / Sandbox (race detector) (push) Successful in 4m31s
Test / Hakurei (race detector) (push) Successful in 5m19s
Test / Hakurei (push) Successful in 2m12s
Test / Flake checks (push) Successful in 1m31s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m9s
Test / Hpkg (push) Successful in 3m58s
Test / Sandbox (race detector) (push) Successful in 4m31s
Test / Hakurei (race detector) (push) Successful in 5m19s
Test / Hakurei (push) Successful in 2m12s
Test / Flake checks (push) Successful in 1m31s
This corrects minor mistakes in doc comments and adds them for undocumented constants. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
db7051a368
commit
8a91234cb4
@ -11,14 +11,20 @@ import (
|
|||||||
type Enablement byte
|
type Enablement byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// EWayland exposes a wayland pathname socket via security-context-v1.
|
||||||
EWayland Enablement = 1 << iota
|
EWayland Enablement = 1 << iota
|
||||||
|
// EX11 adds the target user via X11 ChangeHosts and exposes the X11 pathname socket.
|
||||||
EX11
|
EX11
|
||||||
|
// EDBus enables the per-container xdg-dbus-proxy daemon.
|
||||||
EDBus
|
EDBus
|
||||||
|
// EPulse copies the PulseAudio cookie to [hst.PrivateTmp] and exposes the PulseAudio socket.
|
||||||
EPulse
|
EPulse
|
||||||
|
|
||||||
|
// EM is a noop.
|
||||||
EM
|
EM
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// String returns a string representation of the flags set on [Enablement].
|
||||||
func (e Enablement) String() string {
|
func (e Enablement) String() string {
|
||||||
switch e {
|
switch e {
|
||||||
case 0:
|
case 0:
|
||||||
@ -51,17 +57,17 @@ func (e Enablement) String() string {
|
|||||||
// NewEnablements returns the address of [Enablement] as [Enablements].
|
// NewEnablements returns the address of [Enablement] as [Enablements].
|
||||||
func NewEnablements(e Enablement) *Enablements { return (*Enablements)(&e) }
|
func NewEnablements(e Enablement) *Enablements { return (*Enablements)(&e) }
|
||||||
|
|
||||||
// enablementsJSON is the [json] representation of the [Enablement] bit field.
|
// Enablements is the [json] adapter for [Enablement].
|
||||||
type enablementsJSON struct {
|
type Enablements Enablement
|
||||||
|
|
||||||
|
// enablementsJSON is the [json] representation of [Enablements].
|
||||||
|
type enablementsJSON = struct {
|
||||||
Wayland bool `json:"wayland,omitempty"`
|
Wayland bool `json:"wayland,omitempty"`
|
||||||
X11 bool `json:"x11,omitempty"`
|
X11 bool `json:"x11,omitempty"`
|
||||||
DBus bool `json:"dbus,omitempty"`
|
DBus bool `json:"dbus,omitempty"`
|
||||||
Pulse bool `json:"pulse,omitempty"`
|
Pulse bool `json:"pulse,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enablements is the [json] adapter for [Enablement].
|
|
||||||
type Enablements Enablement
|
|
||||||
|
|
||||||
// Unwrap returns the underlying [Enablement].
|
// Unwrap returns the underlying [Enablement].
|
||||||
func (e *Enablements) Unwrap() Enablement {
|
func (e *Enablements) Unwrap() Enablement {
|
||||||
if e == nil {
|
if e == nil {
|
||||||
|
11
hst/fs.go
11
hst/fs.go
@ -47,17 +47,16 @@ type Ops interface {
|
|||||||
Etc(host *check.Absolute, prefix string) Ops
|
Etc(host *check.Absolute, prefix string) Ops
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApplyState holds the address of [container.Ops] and any relevant application state.
|
// ApplyState holds the address of [Ops] and any relevant application state.
|
||||||
type ApplyState struct {
|
type ApplyState struct {
|
||||||
// AutoEtcPrefix is the prefix for [container.AutoEtcOp].
|
// AutoEtcPrefix is the prefix for [FSBind] in autoetc [FSBind.Special] condition.
|
||||||
AutoEtcPrefix string
|
AutoEtcPrefix string
|
||||||
|
|
||||||
Ops
|
Ops
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
// ErrFSNull is returned by [json] on encountering a null [FilesystemConfig] value.
|
||||||
ErrFSNull = errors.New("unexpected null in mount point")
|
var ErrFSNull = errors.New("unexpected null in mount point")
|
||||||
)
|
|
||||||
|
|
||||||
// FSTypeError is returned when [ContainerConfig.Filesystem] contains an entry with invalid type.
|
// FSTypeError is returned when [ContainerConfig.Filesystem] contains an entry with invalid type.
|
||||||
type FSTypeError string
|
type FSTypeError string
|
||||||
@ -90,7 +89,7 @@ func (f *FilesystemConfigJSON) Valid() bool {
|
|||||||
return f != nil && f.FilesystemConfig != nil && f.FilesystemConfig.Valid()
|
return f != nil && f.FilesystemConfig != nil && f.FilesystemConfig.Valid()
|
||||||
}
|
}
|
||||||
|
|
||||||
// fsType holds the string representation of a [FilesystemConfig]'s concrete type.
|
// fsType holds the string representation of the concrete type of [FilesystemConfig].
|
||||||
type fsType struct {
|
type fsType struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
@ -16,22 +16,23 @@ const FilesystemBind = "bind"
|
|||||||
|
|
||||||
// FSBind represents a host to container bind mount.
|
// FSBind represents a host to container bind mount.
|
||||||
type FSBind struct {
|
type FSBind struct {
|
||||||
// mount point in container, same as Source if empty
|
// Pathname in the container mount namespace. Same as Source if nil.
|
||||||
Target *check.Absolute `json:"dst,omitempty"`
|
Target *check.Absolute `json:"dst,omitempty"`
|
||||||
// host filesystem path to make available to the container
|
// Pathname in the init mount namespace. Must not be nil.
|
||||||
Source *check.Absolute `json:"src"`
|
Source *check.Absolute `json:"src"`
|
||||||
// do not mount Target read-only
|
// Do not remount Target read-only.
|
||||||
|
// This has no effect if Source is mounted read-only in the init mount namespace.
|
||||||
Write bool `json:"write,omitempty"`
|
Write bool `json:"write,omitempty"`
|
||||||
// do not disable device files on Target, implies Write
|
// Allow access to devices (special files) on Target, implies Write.
|
||||||
Device bool `json:"dev,omitempty"`
|
Device bool `json:"dev,omitempty"`
|
||||||
// create Source as a directory if it does not exist
|
// Create Source as a directory in the init mount namespace if it does not exist.
|
||||||
Ensure bool `json:"ensure,omitempty"`
|
Ensure bool `json:"ensure,omitempty"`
|
||||||
// skip this mount point if Source does not exist
|
// Silently skip this mount point if Source does not exist in the init mount namespace.
|
||||||
Optional bool `json:"optional,omitempty"`
|
Optional bool `json:"optional,omitempty"`
|
||||||
|
|
||||||
// enable special behaviour:
|
/* Enable special behaviour:
|
||||||
// for autoroot, Target must be set to [fhs.AbsRoot];
|
For autoroot: Target must be [fhs.Root].
|
||||||
// for autoetc, Target must be set to [fhs.AbsEtc]
|
For autoetc: Target must be [fhs.Etc]. */
|
||||||
Special bool `json:"special,omitempty"`
|
Special bool `json:"special,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,13 +15,13 @@ const FilesystemEphemeral = "ephemeral"
|
|||||||
|
|
||||||
// FSEphemeral represents an ephemeral container mount point.
|
// FSEphemeral represents an ephemeral container mount point.
|
||||||
type FSEphemeral struct {
|
type FSEphemeral struct {
|
||||||
// mount point in container
|
// Pathname in the container mount namespace.
|
||||||
Target *check.Absolute `json:"dst,omitempty"`
|
Target *check.Absolute `json:"dst"`
|
||||||
// do not mount filesystem read-only
|
// Do not mount filesystem read-only.
|
||||||
Write bool `json:"write,omitempty"`
|
Write bool `json:"write,omitempty"`
|
||||||
// upper limit on the size of the filesystem
|
// Upper limit on the size of the filesystem.
|
||||||
Size int `json:"size,omitempty"`
|
Size int `json:"size,omitempty"`
|
||||||
// initial permission bits of the new filesystem
|
// Initial permission bits of the new filesystem.
|
||||||
Perm os.FileMode `json:"perm,omitempty"`
|
Perm os.FileMode `json:"perm,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,11 +14,11 @@ const FilesystemLink = "link"
|
|||||||
|
|
||||||
// FSLink represents a symlink in the container filesystem.
|
// FSLink represents a symlink in the container filesystem.
|
||||||
type FSLink struct {
|
type FSLink struct {
|
||||||
// link path in container
|
// Pathname in the container mount namespace.
|
||||||
Target *check.Absolute `json:"dst"`
|
Target *check.Absolute `json:"dst"`
|
||||||
// linkname the symlink points to
|
// Arbitrary linkname value store in the symlink.
|
||||||
Linkname string `json:"linkname"`
|
Linkname string `json:"linkname"`
|
||||||
// whether to dereference linkname before creating the link
|
// Whether to treat Linkname as an absolute pathname and dereference before creating the link.
|
||||||
Dereference bool `json:"dereference,omitempty"`
|
Dereference bool `json:"dereference,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,14 +14,14 @@ const FilesystemOverlay = "overlay"
|
|||||||
|
|
||||||
// FSOverlay represents an overlay mount point.
|
// FSOverlay represents an overlay mount point.
|
||||||
type FSOverlay struct {
|
type FSOverlay struct {
|
||||||
// mount point in container
|
// Pathname in the container mount namespace.
|
||||||
Target *check.Absolute `json:"dst"`
|
Target *check.Absolute `json:"dst"`
|
||||||
|
|
||||||
// any filesystem, does not need to be on a writable filesystem, must not be nil
|
// Any filesystem, does not need to be on a writable filesystem, must not be nil.
|
||||||
Lower []*check.Absolute `json:"lower"`
|
Lower []*check.Absolute `json:"lower"`
|
||||||
// the upperdir is normally on a writable filesystem, leave as nil to mount Lower readonly
|
// The upperdir is normally on a writable filesystem, leave as nil to mount Lower readonly.
|
||||||
Upper *check.Absolute `json:"upper,omitempty"`
|
Upper *check.Absolute `json:"upper,omitempty"`
|
||||||
// the workdir needs to be an empty directory on the same filesystem as Upper, must not be nil if Upper is populated
|
// The workdir needs to be an empty directory on the same filesystem as Upper, must not be nil if Upper is populated.
|
||||||
Work *check.Absolute `json:"work,omitempty"`
|
Work *check.Absolute `json:"work,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
hst/hst.go
15
hst/hst.go
@ -12,9 +12,12 @@ import (
|
|||||||
|
|
||||||
// An AppError is returned while starting an app according to [hst.Config].
|
// An AppError is returned while starting an app according to [hst.Config].
|
||||||
type AppError struct {
|
type AppError struct {
|
||||||
Step string
|
// A user-facing description of where the error occurred.
|
||||||
|
Step string `json:"step"`
|
||||||
|
// The underlying error value.
|
||||||
Err error
|
Err error
|
||||||
Msg string
|
// An arbitrary error message, overriding the return value of Message if not empty.
|
||||||
|
Msg string `json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *AppError) Error() string { return e.Err.Error() }
|
func (e *AppError) Error() string { return e.Err.Error() }
|
||||||
@ -38,13 +41,13 @@ func (e *AppError) Message() string {
|
|||||||
|
|
||||||
// Paths contains environment-dependent paths used by hakurei.
|
// Paths contains environment-dependent paths used by hakurei.
|
||||||
type Paths struct {
|
type Paths struct {
|
||||||
// temporary directory returned by [os.TempDir] (usually `/tmp`)
|
// Temporary directory returned by [os.TempDir], usually equivalent to [fhs.AbsTmp].
|
||||||
TempDir *check.Absolute `json:"temp_dir"`
|
TempDir *check.Absolute `json:"temp_dir"`
|
||||||
// path to shared directory (usually `/tmp/hakurei.%d`, [Info.User])
|
// Shared directory specific to the hsu userid, usually (`/tmp/hakurei.%d`, [Info.User]).
|
||||||
SharePath *check.Absolute `json:"share_path"`
|
SharePath *check.Absolute `json:"share_path"`
|
||||||
// XDG_RUNTIME_DIR value (usually `/run/user/%d`, uid)
|
// Checked XDG_RUNTIME_DIR value, usually (`/run/user/%d`, uid).
|
||||||
RuntimePath *check.Absolute `json:"runtime_path"`
|
RuntimePath *check.Absolute `json:"runtime_path"`
|
||||||
// application runtime directory (usually `/run/user/%d/hakurei`)
|
// Shared directory specific to the hsu userid located in RuntimePath, usually (`/run/user/%d/hakurei`, uid).
|
||||||
RunDirPath *check.Absolute `json:"run_dir_path"`
|
RunDirPath *check.Absolute `json:"run_dir_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user