mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
* add support for idmapped mounts to start-sdk * misc fixes * misc fixes * add default to textarea * fix iptables masquerade rule * fix textarea types * more fixes * better logging for rsync * fix tty size * fix wg conf generation for android * disable file mounts on dependencies * mostly there, some styling issues (#3069) * mostly there, some styling issues * fix: address comments (#3070) * fix: address comments * fix: fix * show SSL for any address with secure protocol and ssl added * better sorting and messaging --------- Co-authored-by: Alex Inkin <alexander@inkin.ru> * fixes for nextcloud * allow sidebar navigation during service state traansitions * wip: x-forwarded headers * implement x-forwarded-for proxy * lowercase domain names and fix warning popover bug * fix http2 websockets * fix websocket retry behavior * add arch filters to s9pk pack * use docker for start-cli install * add version range to package signer on registry * fix rcs < 0 * fix user information parsing * refactor service interface getters * disable idmaps * build fixes * update docker login action * streamline build * add start-cli workflow * rename * riscv64gc * fix ui packing * no default features on cli * make cli depend on GIT_HASH * more build fixes * more build fixes * interpolate arch within dockerfile * fix tests * add launch ui to service page plus other small improvements (#3075) * add launch ui to service page plus other small improvements * revert translation disable * add spinner to service list if service is health and loading * chore: some visual tune up * chore: update Taiga UI --------- Co-authored-by: waterplea <alexander@inkin.ru> * fix backups * feat: use arm hosted runners and don't fail when apt package does not exist (#3076) --------- Co-authored-by: Matt Hill <mattnine@protonmail.com> Co-authored-by: Shadowy Super Coder <musashidisciple@proton.me> Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com> Co-authored-by: Alex Inkin <alexander@inkin.ru> Co-authored-by: Remco Ros <remcoros@live.nl>
169 lines
4.6 KiB
TypeScript
169 lines
4.6 KiB
TypeScript
import * as T from "../../../base/lib/types"
|
|
import { IdMap, MountOptions } from "../util/SubContainer"
|
|
|
|
type MountArray = { mountpoint: string; options: MountOptions }[]
|
|
|
|
type SharedOptions = {
|
|
/** The path within the resource to mount. Use `null` to mount the entire resource */
|
|
subpath: string | null
|
|
/** Where to mount the resource. e.g. /data */
|
|
mountpoint: string
|
|
/**
|
|
* Whether to mount this as a file or directory
|
|
*
|
|
* defaults to "directory"
|
|
* */
|
|
type?: "file" | "directory" | "infer"
|
|
// /**
|
|
// * Whether to map uids/gids for the mount
|
|
// *
|
|
// * https://www.kernel.org/doc/html/latest/filesystems/idmappings.html
|
|
// */
|
|
// idmap?: {
|
|
// /** The (starting) id of the data on the filesystem (u) */
|
|
// fromId: number
|
|
// /** The (starting) id of the data in the mount point (k) */
|
|
// toId: number
|
|
// /**
|
|
// * Optional: the number of incremental ids to map (r)
|
|
// *
|
|
// * defaults to 1
|
|
// * */
|
|
// range?: number
|
|
// }[]
|
|
}
|
|
|
|
type VolumeOpts<Manifest extends T.SDKManifest> = {
|
|
/** The ID of the volume to mount. Must be one of the volume IDs defined in the manifest */
|
|
volumeId: Manifest["volumes"][number]
|
|
/** Whether or not the resource should be readonly for this subcontainer */
|
|
readonly: boolean
|
|
} & SharedOptions
|
|
|
|
type DependencyOpts<Manifest extends T.SDKManifest> = {
|
|
/** The ID of the dependency */
|
|
dependencyId: Manifest["id"]
|
|
/** The ID of the volume to mount. Must be one of the volume IDs defined in the manifest of the dependency */
|
|
volumeId: Manifest["volumes"][number]
|
|
/** Whether or not the resource should be readonly for this subcontainer */
|
|
readonly: boolean
|
|
} & SharedOptions
|
|
|
|
export class Mounts<
|
|
Manifest extends T.SDKManifest,
|
|
Backups extends SharedOptions = never,
|
|
> {
|
|
private constructor(
|
|
readonly volumes: VolumeOpts<Manifest>[],
|
|
readonly assets: SharedOptions[],
|
|
readonly dependencies: DependencyOpts<T.SDKManifest>[],
|
|
readonly backups: Backups[],
|
|
) {}
|
|
|
|
static of<Manifest extends T.SDKManifest>() {
|
|
return new Mounts<Manifest>([], [], [], [])
|
|
}
|
|
|
|
mountVolume(options: VolumeOpts<Manifest>) {
|
|
return new Mounts<Manifest, Backups>(
|
|
[...this.volumes, options],
|
|
[...this.assets],
|
|
[...this.dependencies],
|
|
[...this.backups],
|
|
)
|
|
}
|
|
|
|
mountAssets(options: SharedOptions) {
|
|
return new Mounts<Manifest, Backups>(
|
|
[...this.volumes],
|
|
[...this.assets, options],
|
|
[...this.dependencies],
|
|
[...this.backups],
|
|
)
|
|
}
|
|
|
|
mountDependency<DependencyManifest extends T.SDKManifest>(
|
|
options: DependencyOpts<DependencyManifest>,
|
|
) {
|
|
return new Mounts<Manifest, Backups>(
|
|
[...this.volumes],
|
|
[...this.assets],
|
|
[...this.dependencies, options],
|
|
[...this.backups],
|
|
)
|
|
}
|
|
|
|
mountBackups(options: SharedOptions) {
|
|
return new Mounts<
|
|
Manifest,
|
|
{
|
|
subpath: string | null
|
|
mountpoint: string
|
|
}
|
|
>(
|
|
[...this.volumes],
|
|
[...this.assets],
|
|
[...this.dependencies],
|
|
[...this.backups, options],
|
|
)
|
|
}
|
|
|
|
build(): MountArray {
|
|
const mountpoints = new Set()
|
|
for (let mountpoint of this.volumes
|
|
.map((v) => v.mountpoint)
|
|
.concat(this.assets.map((a) => a.mountpoint))
|
|
.concat(this.dependencies.map((d) => d.mountpoint))) {
|
|
if (mountpoints.has(mountpoint)) {
|
|
throw new Error(
|
|
`cannot mount more than once to mountpoint ${mountpoint}`,
|
|
)
|
|
}
|
|
mountpoints.add(mountpoint)
|
|
}
|
|
return ([] as MountArray)
|
|
.concat(
|
|
this.volumes.map((v) => ({
|
|
mountpoint: v.mountpoint,
|
|
options: {
|
|
type: "volume",
|
|
volumeId: v.volumeId,
|
|
subpath: v.subpath,
|
|
readonly: v.readonly,
|
|
filetype: v.type ?? "directory",
|
|
idmap: [],
|
|
},
|
|
})),
|
|
)
|
|
.concat(
|
|
this.assets.map((a) => ({
|
|
mountpoint: a.mountpoint,
|
|
options: {
|
|
type: "assets",
|
|
subpath: a.subpath,
|
|
filetype: a.type ?? "directory",
|
|
idmap: [],
|
|
},
|
|
})),
|
|
)
|
|
.concat(
|
|
this.dependencies.map((d) => ({
|
|
mountpoint: d.mountpoint,
|
|
options: {
|
|
type: "pointer",
|
|
packageId: d.dependencyId,
|
|
volumeId: d.volumeId,
|
|
subpath: d.subpath,
|
|
readonly: d.readonly,
|
|
filetype: d.type ?? "directory",
|
|
idmap: [],
|
|
},
|
|
})),
|
|
)
|
|
}
|
|
}
|
|
|
|
const a = Mounts.of().mountBackups({ subpath: null, mountpoint: "" })
|
|
// @ts-expect-error
|
|
const m: Mounts<T.SDKManifest, never> = a
|