@highstate/proxmox 0.9.10 → 0.9.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-2VWLHCZS.js → chunk-GX5AZIC4.js} +6 -2
- package/dist/chunk-GX5AZIC4.js.map +1 -0
- package/dist/connection/index.js +3 -2
- package/dist/connection/index.js.map +1 -1
- package/dist/existing-image/index.js +1 -1
- package/dist/highstate.manifest.json +4 -4
- package/dist/image/index.js +2 -2
- package/dist/image/index.js.map +1 -1
- package/dist/virtual-machine/index.js +32 -14
- package/dist/virtual-machine/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/chunk-2VWLHCZS.js.map +0 -1
@@ -10,7 +10,11 @@ function createProvider(cluster) {
|
|
10
10
|
insecure: cluster2.insecure,
|
11
11
|
username: cluster2.username,
|
12
12
|
password: cluster2.password,
|
13
|
-
apiToken: cluster2.apiToken
|
13
|
+
apiToken: cluster2.apiToken,
|
14
|
+
ssh: cluster2.sshKeyPair ? {
|
15
|
+
privateKey: cluster2.sshKeyPair.privateKey,
|
16
|
+
username: cluster2.username
|
17
|
+
} : void 0
|
14
18
|
});
|
15
19
|
})
|
16
20
|
);
|
@@ -19,4 +23,4 @@ function createProvider(cluster) {
|
|
19
23
|
export {
|
20
24
|
createProvider
|
21
25
|
};
|
22
|
-
//# sourceMappingURL=chunk-
|
26
|
+
//# sourceMappingURL=chunk-GX5AZIC4.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/provider.ts"],"sourcesContent":["import { output, toPromise, type EntityInput } from \"@highstate/pulumi\"\nimport { Provider } from \"@muhlba91/pulumi-proxmoxve\"\nimport { proxmox } from \"@highstate/library\"\n\nexport function createProvider(\n cluster: EntityInput<typeof proxmox.clusterEntity>,\n): Promise<Provider> {\n return toPromise(\n output(cluster).apply(cluster => {\n return new Provider(\"proxmox\", {\n endpoint: cluster.endpoint,\n insecure: cluster.insecure,\n\n username: cluster.username,\n password: cluster.password,\n\n apiToken: cluster.apiToken,\n\n ssh: cluster.sshKeyPair\n ? {\n privateKey: cluster.sshKeyPair.privateKey,\n username: cluster.username,\n }\n : undefined,\n })\n }),\n )\n}\n"],"mappings":";AAAA,SAAS,QAAQ,iBAAmC;AACpD,SAAS,gBAAgB;AACzB,OAAwB;AAEjB,SAAS,eACd,SACmB;AACnB,SAAO;AAAA,IACL,OAAO,OAAO,EAAE,MAAM,CAAAA,aAAW;AAC/B,aAAO,IAAI,SAAS,WAAW;AAAA,QAC7B,UAAUA,SAAQ;AAAA,QAClB,UAAUA,SAAQ;AAAA,QAElB,UAAUA,SAAQ;AAAA,QAClB,UAAUA,SAAQ;AAAA,QAElB,UAAUA,SAAQ;AAAA,QAElB,KAAKA,SAAQ,aACT;AAAA,UACE,YAAYA,SAAQ,WAAW;AAAA,UAC/B,UAAUA,SAAQ;AAAA,QACpB,IACA;AAAA,MACN,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;","names":["cluster"]}
|
package/dist/connection/index.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
import { proxmox } from "@highstate/library";
|
3
3
|
import { forUnit, output, toPromise } from "@highstate/pulumi";
|
4
4
|
import { cluster, storage, Provider } from "@muhlba91/pulumi-proxmoxve";
|
5
|
-
var { args, secrets, outputs } = forUnit(proxmox.connection);
|
5
|
+
var { args, secrets, inputs, outputs } = forUnit(proxmox.connection);
|
6
6
|
var provider = await toPromise(
|
7
7
|
output({ args, secrets }).apply(({ args: args2, secrets: secrets2 }) => {
|
8
8
|
return new Provider("proxmox", {
|
@@ -37,7 +37,8 @@ var proxmoxCluster = output({
|
|
37
37
|
defaultNodeName: nodeName,
|
38
38
|
defaultDatastoreId: datastoreId,
|
39
39
|
password: secrets.password,
|
40
|
-
apiToken: secrets.apiToken
|
40
|
+
apiToken: secrets.apiToken,
|
41
|
+
sshKeyPair: inputs.sshKeyPair
|
41
42
|
});
|
42
43
|
var connection_default = outputs({
|
43
44
|
proxmoxCluster,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/connection/index.ts"],"sourcesContent":["import type { EntityValue, Output } from \"@highstate/pulumi\"\nimport { proxmox } from \"@highstate/library\"\nimport { forUnit, output, toPromise } from \"@highstate/pulumi\"\nimport { cluster, storage, Provider } from \"@muhlba91/pulumi-proxmoxve\"\n\nconst { args, secrets, outputs } = forUnit(proxmox.connection)\n\nconst provider = await toPromise(\n output({ args, secrets }).apply(({ args, secrets }) => {\n return new Provider(\"proxmox\", {\n endpoint: args.endpoint,\n insecure: args.insecure,\n\n username: args.username,\n password: secrets.password,\n\n apiToken: secrets.apiToken,\n })\n }),\n)\n\nconst nodes = await cluster.getNodes({ provider })\nif (nodes.names.length === 0) {\n throw new Error(\"No nodes found\")\n}\n\nconst nodeName = args.defaultNodeName ?? nodes.names[0]\nif (!nodes.names.includes(nodeName)) {\n throw new Error(`Node '${nodeName}' not found in the cluster`)\n}\n\nconst datastores = await storage.getDatastores({ nodeName }, { provider })\nif (datastores.datastoreIds.length === 0) {\n throw new Error(`No datastores found in the node '${nodeName}'`)\n}\n\nconst datastoreId = args.defaultDatastoreId ?? datastores.datastoreIds[0]\nif (!datastores.datastoreIds.includes(datastoreId)) {\n throw new Error(`Datastore '${datastoreId}' not found in the node '${nodeName}'`)\n}\n\nconst proxmoxCluster: Output<EntityValue<typeof proxmox.clusterEntity>> = output({\n endpoint: args.endpoint,\n insecure: args.insecure,\n username: args.username,\n defaultNodeName: nodeName,\n defaultDatastoreId: datastoreId,\n password: secrets.password,\n apiToken: secrets.apiToken,\n})\n\nexport default outputs({\n proxmoxCluster,\n $status: {\n defaultNodeName: {\n value: proxmoxCluster.defaultNodeName,\n },\n defaultDatastoreId: {\n value: proxmoxCluster.defaultDatastoreId,\n },\n },\n})\n"],"mappings":";AACA,SAAS,eAAe;AACxB,SAAS,SAAS,QAAQ,iBAAiB;AAC3C,SAAS,SAAS,SAAS,gBAAgB;AAE3C,IAAM,EAAE,MAAM,SAAS,QAAQ,IAAI,QAAQ,QAAQ,UAAU;
|
1
|
+
{"version":3,"sources":["../../src/connection/index.ts"],"sourcesContent":["import type { EntityValue, Output } from \"@highstate/pulumi\"\nimport { proxmox } from \"@highstate/library\"\nimport { forUnit, output, toPromise } from \"@highstate/pulumi\"\nimport { cluster, storage, Provider } from \"@muhlba91/pulumi-proxmoxve\"\n\nconst { args, secrets, inputs, outputs } = forUnit(proxmox.connection)\n\nconst provider = await toPromise(\n output({ args, secrets }).apply(({ args, secrets }) => {\n return new Provider(\"proxmox\", {\n endpoint: args.endpoint,\n insecure: args.insecure,\n\n username: args.username,\n password: secrets.password,\n\n apiToken: secrets.apiToken,\n })\n }),\n)\n\nconst nodes = await cluster.getNodes({ provider })\nif (nodes.names.length === 0) {\n throw new Error(\"No nodes found\")\n}\n\nconst nodeName = args.defaultNodeName ?? nodes.names[0]\nif (!nodes.names.includes(nodeName)) {\n throw new Error(`Node '${nodeName}' not found in the cluster`)\n}\n\nconst datastores = await storage.getDatastores({ nodeName }, { provider })\nif (datastores.datastoreIds.length === 0) {\n throw new Error(`No datastores found in the node '${nodeName}'`)\n}\n\nconst datastoreId = args.defaultDatastoreId ?? datastores.datastoreIds[0]\nif (!datastores.datastoreIds.includes(datastoreId)) {\n throw new Error(`Datastore '${datastoreId}' not found in the node '${nodeName}'`)\n}\n\nconst proxmoxCluster: Output<EntityValue<typeof proxmox.clusterEntity>> = output({\n endpoint: args.endpoint,\n insecure: args.insecure,\n username: args.username,\n defaultNodeName: nodeName,\n defaultDatastoreId: datastoreId,\n password: secrets.password,\n apiToken: secrets.apiToken,\n sshKeyPair: inputs.sshKeyPair,\n})\n\nexport default outputs({\n proxmoxCluster,\n $status: {\n defaultNodeName: {\n value: proxmoxCluster.defaultNodeName,\n },\n defaultDatastoreId: {\n value: proxmoxCluster.defaultDatastoreId,\n },\n },\n})\n"],"mappings":";AACA,SAAS,eAAe;AACxB,SAAS,SAAS,QAAQ,iBAAiB;AAC3C,SAAS,SAAS,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rB,CAAC;AAED,IAAO,qBAAQ,QAAQ;AAAA,EACrB;AAAA,EACA,SAAS;AAAA,IACP,iBAAiB;AAAA,MACf,OAAO,eAAe;AAAA,IACxB;AAAA,IACA,oBAAoB;AAAA,MAClB,OAAO,eAAe;AAAA,IACxB;AAAA,EACF;AACF,CAAC;","names":["args","secrets"]}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"sourceHashes": {
|
3
|
-
"./dist/connection/index.js": "
|
4
|
-
"./dist/virtual-machine/index.js": "
|
5
|
-
"./dist/existing-image/index.js": "
|
6
|
-
"./dist/image/index.js": "
|
3
|
+
"./dist/connection/index.js": "ca01a5559a884dcc66b98ed026fb8e85afe907cd52000118939471086dfac6e1",
|
4
|
+
"./dist/virtual-machine/index.js": "6f99ac6b32abca47af8e1e3dc446e3319b8f48b876b42d4819d0a009450d3721",
|
5
|
+
"./dist/existing-image/index.js": "c4cf6d7d561477b540b9d1e8acc91e2a38f0c62510937b292ebf9bdcf23e77ac",
|
6
|
+
"./dist/image/index.js": "552f774dc3ccf6ee51f23126f1516736c46c094aff1b30b0a5c247e1c0d9b121"
|
7
7
|
}
|
8
8
|
}
|
package/dist/image/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
createProvider
|
3
|
-
} from "../chunk-
|
3
|
+
} from "../chunk-GX5AZIC4.js";
|
4
4
|
|
5
5
|
// src/image/index.ts
|
6
6
|
import { proxmox } from "@highstate/library";
|
@@ -14,7 +14,7 @@ var file = new download.File(
|
|
14
14
|
contentType: "iso",
|
15
15
|
checksumAlgorithm: "sha256",
|
16
16
|
checksum: args.sha256,
|
17
|
-
datastoreId: args.datastoreId ?? inputs.proxmoxCluster.defaultDatastoreId
|
17
|
+
datastoreId: args.datastoreId ?? inputs.proxmoxCluster.defaultDatastoreId,
|
18
18
|
url: args.url,
|
19
19
|
nodeName: args.nodeName ?? inputs.proxmoxCluster.defaultNodeName,
|
20
20
|
fileName: output(args.url).apply(getNameByUrl).apply(([name2, extension]) => `${name2}-${args.sha256}.${extension}`)
|
package/dist/image/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/image/index.ts"],"sourcesContent":["import { proxmox } from \"@highstate/library\"\nimport { forUnit, output } from \"@highstate/pulumi\"\nimport { download } from \"@muhlba91/pulumi-proxmoxve\"\nimport { createProvider } from \"../provider\"\n\nconst { name, args, inputs, outputs } = forUnit(proxmox.image)\n\nconst provider = await createProvider(inputs.proxmoxCluster)\n\nconst file = new download.File(\n name,\n {\n contentType: \"iso\",\n checksumAlgorithm: \"sha256\",\n checksum: args.sha256,\n\n datastoreId
|
1
|
+
{"version":3,"sources":["../../src/image/index.ts"],"sourcesContent":["import { proxmox } from \"@highstate/library\"\nimport { forUnit, output } from \"@highstate/pulumi\"\nimport { download } from \"@muhlba91/pulumi-proxmoxve\"\nimport { createProvider } from \"../provider\"\n\nconst { name, args, inputs, outputs } = forUnit(proxmox.image)\n\nconst provider = await createProvider(inputs.proxmoxCluster)\n\nconst file = new download.File(\n name,\n {\n contentType: \"iso\",\n checksumAlgorithm: \"sha256\",\n checksum: args.sha256,\n\n datastoreId: args.datastoreId ?? inputs.proxmoxCluster.defaultDatastoreId,\n\n url: args.url,\n nodeName: args.nodeName ?? inputs.proxmoxCluster.defaultNodeName,\n\n fileName: output(args.url)\n .apply(getNameByUrl)\n .apply(([name, extension]) => `${name}-${args.sha256}.${extension}`),\n },\n { provider },\n)\n\nfunction getNameByUrl(url: string): [name: string, extension: string] {\n const fullName = url.split(\"/\").pop()!.split(\"?\")[0]\n const parts = fullName.split(\".\")\n\n const name = parts.slice(0, parts.length - 1).join(\".\")\n const extension = parts[parts.length - 1]\n\n return [name, extension]\n}\n\nexport default outputs({\n image: {\n id: file.id,\n },\n})\n"],"mappings":";;;;;AAAA,SAAS,eAAe;AACxB,SAAS,SAAS,cAAc;AAChC,SAAS,gBAAgB;AAGzB,IAAM,EAAE,MAAM,MAAM,QAAQ,QAAQ,IAAI,QAAQ,QAAQ,KAAK;AAE7D,IAAM,WAAW,MAAM,eAAe,OAAO,cAAc;AAE3D,IAAM,OAAO,IAAI,SAAS;AAAA,EACxB;AAAA,EACA;AAAA,IACE,aAAa;AAAA,IACb,mBAAmB;AAAA,IACnB,UAAU,KAAK;AAAA,IAEf,aAAa,KAAK,eAAe,OAAO,eAAe;AAAA,IAEvD,KAAK,KAAK;AAAA,IACV,UAAU,KAAK,YAAY,OAAO,eAAe;AAAA,IAEjD,UAAU,OAAO,KAAK,GAAG,EACtB,MAAM,YAAY,EAClB,MAAM,CAAC,CAACA,OAAM,SAAS,MAAM,GAAGA,KAAI,IAAI,KAAK,MAAM,IAAI,SAAS,EAAE;AAAA,EACvE;AAAA,EACA,EAAE,SAAS;AACb;AAEA,SAAS,aAAa,KAAgD;AACpE,QAAM,WAAW,IAAI,MAAM,GAAG,EAAE,IAAI,EAAG,MAAM,GAAG,EAAE,CAAC;AACnD,QAAM,QAAQ,SAAS,MAAM,GAAG;AAEhC,QAAMA,QAAO,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,EAAE,KAAK,GAAG;AACtD,QAAM,YAAY,MAAM,MAAM,SAAS,CAAC;AAExC,SAAO,CAACA,OAAM,SAAS;AACzB;AAEA,IAAO,gBAAQ,QAAQ;AAAA,EACrB,OAAO;AAAA,IACL,IAAI,KAAK;AAAA,EACX;AACF,CAAC;","names":["name"]}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import {
|
2
2
|
createProvider
|
3
|
-
} from "../chunk-
|
3
|
+
} from "../chunk-GX5AZIC4.js";
|
4
4
|
|
5
5
|
// src/virtual-machine/index.ts
|
6
6
|
import { proxmox } from "@highstate/library";
|
7
7
|
import { forUnit, output, toPromise } from "@highstate/pulumi";
|
8
|
-
import { vm } from "@muhlba91/pulumi-proxmoxve";
|
8
|
+
import { vm, storage } from "@muhlba91/pulumi-proxmoxve";
|
9
9
|
import {
|
10
10
|
createServerEntity,
|
11
11
|
createSshTerminal,
|
@@ -27,21 +27,24 @@ var machine = new vm.VirtualMachine(
|
|
27
27
|
cpu: {
|
28
28
|
cores: args.cores,
|
29
29
|
sockets: args.sockets,
|
30
|
-
type: args.cpuType
|
30
|
+
type: args.cpuType
|
31
31
|
},
|
32
32
|
memory: {
|
33
33
|
dedicated: args.memory
|
34
34
|
},
|
35
|
-
cdrom: {
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
},
|
35
|
+
// cdrom: {
|
36
|
+
// enabled: true,
|
37
|
+
// interface: "ide1",
|
38
|
+
// fileId: inputs.image.id,
|
39
|
+
// },
|
40
40
|
disks: [
|
41
41
|
{
|
42
|
-
interface: "
|
42
|
+
interface: "virtio0",
|
43
43
|
size: args.diskSize,
|
44
|
-
|
44
|
+
iothread: true,
|
45
|
+
discard: "on",
|
46
|
+
datastoreId,
|
47
|
+
fileId: inputs.image.id
|
45
48
|
}
|
46
49
|
],
|
47
50
|
networkDevices: [
|
@@ -49,10 +52,10 @@ var machine = new vm.VirtualMachine(
|
|
49
52
|
bridge: args.bridge
|
50
53
|
}
|
51
54
|
],
|
52
|
-
initialization: output(inputs).apply(createCloudInit)
|
53
|
-
bootOrders: ["scsi0", "ide1"]
|
55
|
+
initialization: output(inputs).apply(createCloudInit)
|
56
|
+
// bootOrders: ["scsi0", "ide1"],
|
54
57
|
},
|
55
|
-
{ provider }
|
58
|
+
{ provider, ignoreChanges: ["disks"] }
|
56
59
|
);
|
57
60
|
function findNotLocalHostIpV4(ips) {
|
58
61
|
for (const ip of ips) {
|
@@ -66,6 +69,20 @@ function deriveIpV4Gateway(ip) {
|
|
66
69
|
return ip.split(".").slice(0, 3).join(".") + ".1";
|
67
70
|
}
|
68
71
|
function createCloudInit(resolvedInputs) {
|
72
|
+
let vendorDataFileId;
|
73
|
+
if (args.vendorData) {
|
74
|
+
const file = new storage.File(
|
75
|
+
"vendor-data",
|
76
|
+
{
|
77
|
+
datastoreId,
|
78
|
+
nodeName,
|
79
|
+
contentType: "snippets",
|
80
|
+
sourceRaw: { fileName: `${name}-vendor-data.yaml`, data: args.vendorData }
|
81
|
+
},
|
82
|
+
{ provider }
|
83
|
+
);
|
84
|
+
vendorDataFileId = file.id;
|
85
|
+
}
|
69
86
|
return {
|
70
87
|
datastoreId,
|
71
88
|
interface: "ide2",
|
@@ -82,7 +99,8 @@ function createCloudInit(resolvedInputs) {
|
|
82
99
|
keys: [resolvedInputs.sshKeyPair.publicKey],
|
83
100
|
username: args.sshUser ?? "root",
|
84
101
|
password: secrets.sshPassword
|
85
|
-
}) : void 0
|
102
|
+
}) : void 0,
|
103
|
+
vendorDataFileId
|
86
104
|
};
|
87
105
|
}
|
88
106
|
var ipv4Addresses = await toPromise(machine.ipv4Addresses);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/virtual-machine/index.ts"],"sourcesContent":["import type { VM } from \"@muhlba91/pulumi-proxmoxve/types/input\"\nimport { proxmox } from \"@highstate/library\"\nimport { forUnit, output, toPromise, type Unwrap } from \"@highstate/pulumi\"\nimport { vm } from \"@muhlba91/pulumi-proxmoxve\"\nimport {\n createServerEntity,\n createSshTerminal,\n l3EndpointToString,\n parseL3Endpoint,\n} from \"@highstate/common\"\nimport { createProvider } from \"../provider\"\n\nconst { name, args, inputs, secrets, outputs } = forUnit(proxmox.virtualMachine)\n\nconst provider = await createProvider(inputs.proxmoxCluster)\n\nconst nodeName = args.nodeName ?? inputs.proxmoxCluster.defaultNodeName\nconst datastoreId = args.datastoreId ?? inputs.proxmoxCluster.defaultDatastoreId\n\nconst machine = new vm.VirtualMachine(\n name,\n {\n name,\n nodeName,\n agent: {\n enabled: true,\n },\n cpu: {\n cores: args.cores,\n sockets: args.sockets,\n type: args.cpuType
|
1
|
+
{"version":3,"sources":["../../src/virtual-machine/index.ts"],"sourcesContent":["import type { VM } from \"@muhlba91/pulumi-proxmoxve/types/input\"\nimport { proxmox } from \"@highstate/library\"\nimport { forUnit, output, toPromise, type Input, type Unwrap } from \"@highstate/pulumi\"\nimport { vm, storage } from \"@muhlba91/pulumi-proxmoxve\"\nimport {\n createServerEntity,\n createSshTerminal,\n l3EndpointToString,\n parseL3Endpoint,\n} from \"@highstate/common\"\nimport { createProvider } from \"../provider\"\n\nconst { name, args, inputs, secrets, outputs } = forUnit(proxmox.virtualMachine)\n\nconst provider = await createProvider(inputs.proxmoxCluster)\n\nconst nodeName = args.nodeName ?? inputs.proxmoxCluster.defaultNodeName\nconst datastoreId = args.datastoreId ?? inputs.proxmoxCluster.defaultDatastoreId\n\nconst machine = new vm.VirtualMachine(\n name,\n {\n name,\n nodeName,\n agent: {\n enabled: true,\n },\n cpu: {\n cores: args.cores,\n sockets: args.sockets,\n type: args.cpuType,\n },\n memory: {\n dedicated: args.memory,\n },\n // cdrom: {\n // enabled: true,\n // interface: \"ide1\",\n // fileId: inputs.image.id,\n // },\n disks: [\n {\n interface: \"virtio0\",\n size: args.diskSize,\n iothread: true,\n discard: \"on\",\n datastoreId,\n fileId: inputs.image.id,\n },\n ],\n networkDevices: [\n {\n bridge: args.bridge,\n },\n ],\n initialization: output(inputs).apply(createCloudInit),\n // bootOrders: [\"scsi0\", \"ide1\"],\n },\n { provider, ignoreChanges: [\"disks\"] },\n)\n\nfunction findNotLocalHostIpV4(ips: string[][]): string {\n for (const ip of ips) {\n if (ip[0] && ip[0] !== \"127.0.0.1\") {\n return ip[0]\n }\n }\n\n throw new Error(\"No non-local host IP found\")\n}\n\nfunction deriveIpV4Gateway(ip: string): string {\n return ip.split(\".\").slice(0, 3).join(\".\") + \".1\"\n}\n\nfunction createCloudInit(resolvedInputs: Unwrap<typeof inputs>): VM.VirtualMachineInitialization {\n let vendorDataFileId: Input<string> | undefined\n\n if (args.vendorData) {\n const file = new storage.File(\n \"vendor-data\",\n {\n datastoreId,\n nodeName,\n contentType: \"snippets\",\n sourceRaw: { fileName: `${name}-vendor-data.yaml`, data: args.vendorData },\n },\n { provider },\n )\n\n vendorDataFileId = file.id\n }\n\n return {\n datastoreId,\n interface: \"ide2\",\n ipConfigs: args.ipv4\n ? [\n {\n ipv4: {\n address: args.ipv4,\n gateway: args.ipv4Gateway ?? deriveIpV4Gateway(args.ipv4),\n },\n },\n ]\n : undefined,\n dns: args.dns ? { servers: args.dns } : undefined,\n\n userAccount: resolvedInputs.sshKeyPair\n ? output({\n keys: [resolvedInputs.sshKeyPair.publicKey],\n username: args.sshUser ?? \"root\",\n password: secrets.sshPassword,\n })\n : undefined,\n\n vendorDataFileId,\n }\n}\n\nconst ipv4Addresses = await toPromise(machine.ipv4Addresses)\nconst nonLocalHostIpV4 = findNotLocalHostIpV4(ipv4Addresses)\n\nconst endpoint = parseL3Endpoint(nonLocalHostIpV4)\n\nconst server = createServerEntity(\n name,\n endpoint,\n args.sshPort,\n args.sshUser,\n secrets.sshPassword,\n inputs.sshKeyPair?.privateKey,\n)\n\nexport default outputs({\n server,\n endpoints: [endpoint],\n\n $status: {\n endpoints: [l3EndpointToString(endpoint)],\n hostname: name,\n },\n\n $terminals: [createSshTerminal(server.ssh)],\n})\n"],"mappings":";;;;;AACA,SAAS,eAAe;AACxB,SAAS,SAAS,QAAQ,iBAA0C;AACpE,SAAS,IAAI,eAAe;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,IAAM,EAAE,MAAM,MAAM,QAAQ,SAAS,QAAQ,IAAI,QAAQ,QAAQ,cAAc;AAE/E,IAAM,WAAW,MAAM,eAAe,OAAO,cAAc;AAE3D,IAAM,WAAW,KAAK,YAAY,OAAO,eAAe;AACxD,IAAM,cAAc,KAAK,eAAe,OAAO,eAAe;AAE9D,IAAM,UAAU,IAAI,GAAG;AAAA,EACrB;AAAA,EACA;AAAA,IACE;AAAA,IACA;AAAA,IACA,OAAO;AAAA,MACL,SAAS;AAAA,IACX;AAAA,IACA,KAAK;AAAA,MACH,OAAO,KAAK;AAAA,MACZ,SAAS,KAAK;AAAA,MACd,MAAM,KAAK;AAAA,IACb;AAAA,IACA,QAAQ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MACF;AAAA,IACF,IACA;AAAA,IACJ,KAAK,KAAK,MAAM,EAAE,SAAS,KAAK,IAAI,IAAI;AAAA,IAExC,aAAa,eAAe,aACxB,OAAO;AAAA,MACL,MAAM,CAAC,eAAe,WAAW,SAAS;AAAA,MAC1C,UAAU,KAAK,WAAW;AAAA,MAC1B,UAAU,QAAQ;AAAA,IACpB,CAAC,IACD;AAAA,IAEJ;AAAA,EACF;AACF;AAEA,IAAM,gBAAgB,MAAM,UAAU,QAAQ,aAAa;AAC3D,IAAM,mBAAmB,qBAAqB,aAAa;AAE3D,IAAM,WAAW,gBAAgB,gBAAgB;AAEjD,IAAM,SAAS;AAAA,EACb;AAAA,EACA;AAAA,EACA,KAAK;AAAA,EACL,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO,YAAY;AACrB;AAEA,IAAO,0BAAQ,QAAQ;AAAA,EACrB;AAAA,EACA,WAAW,CAAC,QAAQ;AAAA,EAEpB,SAAS;AAAA,IACP,WAAW,CAAC,mBAAmB,QAAQ,CAAC;AAAA,IACxC,UAAU;AAAA,EACZ;AAAA,EAEA,YAAY,CAAC,kBAAkB,OAAO,GAAG,CAAC;AAC5C,CAAC;","names":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@highstate/proxmox",
|
3
|
-
"version": "0.9.
|
3
|
+
"version": "0.9.11",
|
4
4
|
"type": "module",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -18,14 +18,14 @@
|
|
18
18
|
"build": "highstate build"
|
19
19
|
},
|
20
20
|
"dependencies": {
|
21
|
-
"@highstate/common": "^0.9.
|
22
|
-
"@highstate/contract": "^0.9.
|
23
|
-
"@highstate/library": "^0.9.
|
24
|
-
"@highstate/pulumi": "^0.9.
|
21
|
+
"@highstate/common": "^0.9.11",
|
22
|
+
"@highstate/contract": "^0.9.11",
|
23
|
+
"@highstate/library": "^0.9.11",
|
24
|
+
"@highstate/pulumi": "^0.9.11",
|
25
25
|
"@muhlba91/pulumi-proxmoxve": "^6.17.1"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
|
-
"@highstate/cli": "^0.9.
|
28
|
+
"@highstate/cli": "^0.9.11"
|
29
29
|
},
|
30
|
-
"gitHead": "
|
30
|
+
"gitHead": "d62cae30ea9fadaa1aa4fb3b5734a16cf53810ce"
|
31
31
|
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/provider.ts"],"sourcesContent":["import { output, toPromise, type EntityInput } from \"@highstate/pulumi\"\nimport { Provider } from \"@muhlba91/pulumi-proxmoxve\"\nimport { proxmox } from \"@highstate/library\"\n\nexport function createProvider(\n cluster: EntityInput<typeof proxmox.clusterEntity>,\n): Promise<Provider> {\n return toPromise(\n output(cluster).apply(cluster => {\n return new Provider(\"proxmox\", {\n endpoint: cluster.endpoint,\n insecure: cluster.insecure,\n\n username: cluster.username,\n password: cluster.password,\n\n apiToken: cluster.apiToken,\n })\n }),\n )\n}\n"],"mappings":";AAAA,SAAS,QAAQ,iBAAmC;AACpD,SAAS,gBAAgB;AACzB,OAAwB;AAEjB,SAAS,eACd,SACmB;AACnB,SAAO;AAAA,IACL,OAAO,OAAO,EAAE,MAAM,CAAAA,aAAW;AAC/B,aAAO,IAAI,SAAS,WAAW;AAAA,QAC7B,UAAUA,SAAQ;AAAA,QAClB,UAAUA,SAAQ;AAAA,QAElB,UAAUA,SAAQ;AAAA,QAClB,UAAUA,SAAQ;AAAA,QAElB,UAAUA,SAAQ;AAAA,MACpB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;","names":["cluster"]}
|