From 7e8a4735d4904bbab409378337e4e7ae3677882c Mon Sep 17 00:00:00 2001 From: Bas van den Wollenberg Date: Sat, 21 Mar 2026 05:02:34 +0100 Subject: [PATCH] change imports --- lib/relay-hosts.ts | 3 +- lib/service/mounts.ts | 4 +-- lib/service/networks.ts | 4 +-- lib/service/providers.ts | 6 ++-- lib/service/service.ts | 67 ++++++++++++++++++++-------------------- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/lib/relay-hosts.ts b/lib/relay-hosts.ts index 7b89360..7026033 100644 --- a/lib/relay-hosts.ts +++ b/lib/relay-hosts.ts @@ -1,8 +1,9 @@ import { JSDOM } from "jsdom"; import pMemoize from "p-memoize"; +const PULSAR = "https://pulsar.feeds.blue"; + export const fetchRelays = pMemoize(async () => { - const PULSAR = "https://pulsar.feeds.blue"; const res = await fetch(PULSAR); if (!res.ok) { throw Error(`Error on fetching data from Pulsar: ${res.status}`); diff --git a/lib/service/mounts.ts b/lib/service/mounts.ts index 0013d3b..4f1fc5b 100644 --- a/lib/service/mounts.ts +++ b/lib/service/mounts.ts @@ -1,4 +1,4 @@ -import docker from "@pulumi/docker"; +import { ContainerMount } from "@pulumi/docker/types/input"; import { Input, output, Unwrap } from "@pulumi/pulumi"; type Optional = Pick, K> & Omit; @@ -7,7 +7,7 @@ type CustomMountOpts = { kind?: Input<"directory" | "file">; }; -export type MountOpts = docker.types.input.ContainerMount & CustomMountOpts; +export type MountOpts = ContainerMount & CustomMountOpts; export function _mount({ source, diff --git a/lib/service/networks.ts b/lib/service/networks.ts index c2d07f0..d140159 100644 --- a/lib/service/networks.ts +++ b/lib/service/networks.ts @@ -1,7 +1,7 @@ -import docker from "@pulumi/docker"; +import { Network } from "@pulumi/docker"; import { haringDockerProvider } from "./providers"; -export const defaultNetwork = new docker.Network( +export const defaultNetwork = new Network( "haring", { name: "haring", diff --git a/lib/service/providers.ts b/lib/service/providers.ts index 1c0fe25..016cff3 100644 --- a/lib/service/providers.ts +++ b/lib/service/providers.ts @@ -1,11 +1,11 @@ -import docker from "@pulumi/docker"; +import { Provider } from "@pulumi/docker"; -export const haringDockerProvider = new docker.Provider("haring", { +export const haringDockerProvider = new Provider("haring", { host: "ssh://haring", context: "haring", }); -export const kaneelnasDockerProvider = new docker.Provider("kaneelnas", { +export const kaneelnasDockerProvider = new Provider("kaneelnas", { host: "ssh://kaneelnas", context: "kaneelnas", }); diff --git a/lib/service/service.ts b/lib/service/service.ts index 5e12331..2743bdb 100644 --- a/lib/service/service.ts +++ b/lib/service/service.ts @@ -1,8 +1,6 @@ -import command from "@pulumi/command"; import type { input } from "@pulumi/command/types"; -import docker from "@pulumi/docker"; -import type { Input, Output, Resource } from "@pulumi/pulumi"; -import pulumi, { all, output } from "@pulumi/pulumi"; +import type { CustomResourceOptions, Input, InvokeOptions, Output, Resource } from "@pulumi/pulumi"; +import { all, ComponentResource, output } from "@pulumi/pulumi"; import path from "path"; import { defaultNetwork } from "./networks"; import { convertPorts } from "./ports"; @@ -10,6 +8,8 @@ import { getEnv } from "~lib/env"; import { haringDockerProvider } from "./providers"; import { MountOpts } from "./mounts"; import { ContainerCapabilities, ContainerPort } from "@pulumi/docker/types/input"; +import { remote, local } from "@pulumi/command"; +import { Container, ContainerArgs, getRegistryImage, RemoteImage } from "@pulumi/docker"; export const defaultConnection = { host: getEnv("CONNECTION_HOST"), @@ -22,7 +22,7 @@ type Env = string | number | boolean; type Port = (number | string | ContainerPort)[]; export type ContainerServiceArgs = Partial< - Omit & { + Omit & { localImage: Input; servicePort: Input; subdomain: Input; @@ -42,18 +42,18 @@ export type ContainerServiceArgs = Partial< >; // TODO: turn ContainerService into a factory function like https://sst.dev/docs/examples/#api-gateway-auth -class ContainerService extends pulumi.ComponentResource { - public readonly container: Output; +class ContainerService extends ComponentResource { + public readonly container: Output; public readonly localUrl: Output; public readonly ip: Output; - public readonly mounts: docker.Container["mounts"]; - public readonly envs: docker.Container["envs"]; - public readonly capabilities: docker.Container["capabilities"]; - public readonly ports: docker.Container["ports"]; + public readonly mounts: Container["mounts"]; + public readonly envs: Container["envs"]; + public readonly capabilities: Container["capabilities"]; + public readonly ports: Container["ports"]; private commandConnection: Input; - constructor(name: string, args: ContainerServiceArgs, opts?: pulumi.CustomResourceOptions) { + constructor(name: string, args: ContainerServiceArgs, opts?: CustomResourceOptions) { super("bas:docker:ContainerService", name, args, opts); this.commandConnection = args.commandConnection ?? defaultConnection; @@ -69,13 +69,13 @@ class ContainerService extends pulumi.ComponentResource { const image = args.localImage ?? - new docker.RemoteImage( + new RemoteImage( `${name}`, { name: output(args.image ?? `lscr.io/linuxserver/${name}`).apply(async (image) => - docker - .getRegistryImage({ name: image }, { parent: this }) - .then((registryImage) => `${registryImage.name}@${registryImage.sha256Digest}`), + getRegistryImage({ name: image }, { parent: this }).then( + (registryImage) => `${registryImage.name}@${registryImage.sha256Digest}`, + ), ), keepLocally: true, }, @@ -201,7 +201,7 @@ class ContainerService extends pulumi.ComponentResource { this.capabilities = output(capabilities); this.container = output( - new docker.Container( + new Container( name, { ...args, @@ -220,14 +220,16 @@ class ContainerService extends pulumi.ComponentResource { // healthcheck: {tests} networksAdvanced: args.networkMode ? [] - : pulumi - .output(args.networksAdvanced ?? []) - .apply((networksAdvanced) => [...networksAdvanced, { name: defaultNetwork.name }]), + : output(args.networksAdvanced ?? []).apply((networksAdvanced) => [ + ...networksAdvanced, + { name: defaultNetwork.name }, + ]), hosts: args.networkMode ? [] - : pulumi - .output(args.hosts ?? []) - .apply((hosts) => [{ host: "host.docker.internal", ip: "host-gateway" }, ...hosts]), + : output(args.hosts ?? []).apply((hosts) => [ + { host: "host.docker.internal", ip: "host-gateway" }, + ...hosts, + ]), capabilities, }, { @@ -241,9 +243,8 @@ class ContainerService extends pulumi.ComponentResource { ), ); - this.ip = pulumi - .all([args.networkMode, this.container.networkDatas, defaultNetwork.name]) - .apply(([networkMode, networks, haringNetwork]) => { + this.ip = all([args.networkMode, this.container.networkDatas, defaultNetwork.name]).apply( + ([networkMode, networks, haringNetwork]) => { if (networkMode === "host") { return "host.docker.internal"; } else if (networkMode?.startsWith("container")) { @@ -261,13 +262,14 @@ class ContainerService extends pulumi.ComponentResource { } return net.ipAddress; - }); + }, + ); this.registerOutputs(); } private createRemoteDir(path: string, name: string, index: number) { - return new command.remote.Command( + return new remote.Command( `mkdir-${name}-${index}`, { connection: this.commandConnection, @@ -291,10 +293,7 @@ class ContainerService extends pulumi.ComponentResource { ); } - static async remoteRun( - args: command.local.RunArgs, - opts?: pulumi.InvokeOptions, - ): Promise { + static async remoteRun(args: local.RunArgs, opts?: InvokeOptions): Promise { const newArgs = { ...args, interpreter: [ @@ -302,9 +301,9 @@ class ContainerService extends pulumi.ComponentResource { `-p ${defaultConnection.port}`, `${defaultConnection.user}@${defaultConnection.host}`, ], - } satisfies command.local.RunArgs; + } satisfies local.RunArgs; - return command.local.run(newArgs, { + return local.run(newArgs, { ...opts, }); } -- 2.51.2