@highstate/common 0.9.4 → 0.9.6
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-USV6SHAU.js +530 -0
- package/dist/chunk-USV6SHAU.js.map +1 -0
- package/dist/highstate.manifest.json +9 -5
- package/dist/index.js +33 -7
- package/dist/units/dns/record-set/index.js +18 -0
- package/dist/units/dns/record-set/index.js.map +1 -0
- package/dist/units/existing-server/index.js +34 -0
- package/dist/units/existing-server/index.js.map +1 -0
- package/dist/units/network/l3-endpoint/index.js +15 -0
- package/dist/units/network/l3-endpoint/index.js.map +1 -0
- package/dist/units/network/l4-endpoint/index.js +15 -0
- package/dist/units/network/l4-endpoint/index.js.map +1 -0
- package/dist/{script → units/script}/index.js +5 -6
- package/dist/units/script/index.js.map +1 -0
- package/dist/units/server-dns/index.js +30 -0
- package/dist/units/server-dns/index.js.map +1 -0
- package/dist/units/server-patch/index.js +29 -0
- package/dist/units/server-patch/index.js.map +1 -0
- package/dist/units/ssh/key-pair/index.js +22 -0
- package/dist/units/ssh/key-pair/index.js.map +1 -0
- package/package.json +15 -10
- package/src/shared/command.ts +132 -0
- package/src/shared/dns.ts +209 -21
- package/src/shared/index.ts +2 -2
- package/src/shared/network.ts +311 -0
- package/src/shared/ssh.ts +111 -38
- package/src/units/dns/record-set/index.ts +16 -0
- package/src/units/existing-server/index.ts +34 -0
- package/src/units/network/l3-endpoint/index.ts +9 -0
- package/src/units/network/l4-endpoint/index.ts +9 -0
- package/src/{script → units/script}/index.ts +3 -5
- package/src/units/server-dns/index.ts +26 -0
- package/src/units/server-patch/index.ts +25 -0
- package/src/units/ssh/key-pair/index.ts +16 -0
- package/dist/chunk-ZA27FN5N.js +0 -214
- package/dist/chunk-ZA27FN5N.js.map +0 -1
- package/dist/dns/record/index.js +0 -1
- package/dist/dns/record/index.js.map +0 -1
- package/dist/existing-server/index.js +0 -48
- package/dist/existing-server/index.js.map +0 -1
- package/dist/script/index.js.map +0 -1
- package/dist/ssh/key-pair/index.js +0 -30
- package/dist/ssh/key-pair/index.js.map +0 -1
- package/src/dns/record/index.ts +0 -0
- package/src/existing-server/index.ts +0 -46
- package/src/shared/server.ts +0 -85
- package/src/shared/utils.ts +0 -18
- package/src/ssh/key-pair/index.ts +0 -24
package/dist/index.js
CHANGED
@@ -1,25 +1,51 @@
|
|
1
1
|
import {
|
2
|
+
Command,
|
2
3
|
DnsRecord,
|
3
|
-
|
4
|
+
DnsRecordSet,
|
5
|
+
createServerEntity,
|
4
6
|
createSshTerminal,
|
7
|
+
filterEndpoints,
|
5
8
|
generatePassword,
|
6
9
|
generatePrivateKey,
|
7
|
-
getKeysFromString,
|
8
10
|
getOrCreateSshKeyPair,
|
9
11
|
getServerConnection,
|
12
|
+
l34EndpointToString,
|
13
|
+
l3EndpointToCidr,
|
14
|
+
l3EndpointToString,
|
15
|
+
l3ToL4Endpoint,
|
10
16
|
l4EndpointToString,
|
11
|
-
|
12
|
-
|
17
|
+
parseL34Endpoint,
|
18
|
+
parseL3Endpoint,
|
19
|
+
parseL4Endpoint,
|
20
|
+
privateKeyToKeyPair,
|
21
|
+
requireInputL3Endpoint,
|
22
|
+
requireInputL4Endpoint,
|
23
|
+
updateEndpoints,
|
24
|
+
updateEndpointsWithFqdn
|
25
|
+
} from "./chunk-USV6SHAU.js";
|
13
26
|
export {
|
27
|
+
Command,
|
14
28
|
DnsRecord,
|
15
|
-
|
29
|
+
DnsRecordSet,
|
30
|
+
createServerEntity,
|
16
31
|
createSshTerminal,
|
32
|
+
filterEndpoints,
|
17
33
|
generatePassword,
|
18
34
|
generatePrivateKey,
|
19
|
-
getKeysFromString,
|
20
35
|
getOrCreateSshKeyPair,
|
21
36
|
getServerConnection,
|
37
|
+
l34EndpointToString,
|
38
|
+
l3EndpointToCidr,
|
39
|
+
l3EndpointToString,
|
40
|
+
l3ToL4Endpoint,
|
22
41
|
l4EndpointToString,
|
23
|
-
|
42
|
+
parseL34Endpoint,
|
43
|
+
parseL3Endpoint,
|
44
|
+
parseL4Endpoint,
|
45
|
+
privateKeyToKeyPair,
|
46
|
+
requireInputL3Endpoint,
|
47
|
+
requireInputL4Endpoint,
|
48
|
+
updateEndpoints,
|
49
|
+
updateEndpointsWithFqdn
|
24
50
|
};
|
25
51
|
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import {
|
2
|
+
DnsRecordSet
|
3
|
+
} from "../../../chunk-USV6SHAU.js";
|
4
|
+
|
5
|
+
// src/units/dns/record-set/index.ts
|
6
|
+
import { dns } from "@highstate/library";
|
7
|
+
import { forUnit, toPromise } from "@highstate/pulumi";
|
8
|
+
var { name, args, inputs } = forUnit(dns.recordSet);
|
9
|
+
var endpoints = await toPromise(inputs.endpoints);
|
10
|
+
DnsRecordSet.create(name, {
|
11
|
+
type: args.type,
|
12
|
+
providers: inputs.dnsProviders,
|
13
|
+
values: [...args.values, ...endpoints],
|
14
|
+
ttl: args.ttl,
|
15
|
+
priority: args.priority,
|
16
|
+
proxied: args.proxied
|
17
|
+
});
|
18
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/units/dns/record-set/index.ts"],"sourcesContent":["import { dns } from \"@highstate/library\"\nimport { forUnit, toPromise } from \"@highstate/pulumi\"\nimport { DnsRecordSet } from \"../../../shared\"\n\nconst { name, args, inputs } = forUnit(dns.recordSet)\n\nconst endpoints = await toPromise(inputs.endpoints)\n\nDnsRecordSet.create(name, {\n type: args.type,\n providers: inputs.dnsProviders,\n values: [...args.values, ...endpoints],\n ttl: args.ttl,\n priority: args.priority,\n proxied: args.proxied,\n})\n"],"mappings":";;;;;AAAA,SAAS,WAAW;AACpB,SAAS,SAAS,iBAAiB;AAGnC,IAAM,EAAE,MAAM,MAAM,OAAO,IAAI,QAAQ,IAAI,SAAS;AAEpD,IAAM,YAAY,MAAM,UAAU,OAAO,SAAS;AAElD,aAAa,OAAO,MAAM;AAAA,EACxB,MAAM,KAAK;AAAA,EACX,WAAW,OAAO;AAAA,EAClB,QAAQ,CAAC,GAAG,KAAK,QAAQ,GAAG,SAAS;AAAA,EACrC,KAAK,KAAK;AAAA,EACV,UAAU,KAAK;AAAA,EACf,SAAS,KAAK;AAChB,CAAC;","names":[]}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import {
|
2
|
+
createServerEntity,
|
3
|
+
createSshTerminal,
|
4
|
+
l3EndpointToString,
|
5
|
+
requireInputL3Endpoint
|
6
|
+
} from "../../chunk-USV6SHAU.js";
|
7
|
+
|
8
|
+
// src/units/existing-server/index.ts
|
9
|
+
import { common } from "@highstate/library";
|
10
|
+
import { forUnit, toPromise } from "@highstate/pulumi";
|
11
|
+
var { name, args, inputs, secrets, outputs } = forUnit(common.existingServer);
|
12
|
+
var endpoint = await requireInputL3Endpoint(args.endpoint, inputs.endpoint);
|
13
|
+
var privateKey = await toPromise(inputs.sshKeyPair?.privateKey ?? secrets.sshPrivateKey);
|
14
|
+
var server = createServerEntity(
|
15
|
+
name,
|
16
|
+
endpoint,
|
17
|
+
args.sshPort,
|
18
|
+
args.sshUser,
|
19
|
+
secrets.sshPassword,
|
20
|
+
privateKey
|
21
|
+
);
|
22
|
+
var existing_server_default = outputs({
|
23
|
+
server,
|
24
|
+
endpoints: server.endpoints,
|
25
|
+
$status: {
|
26
|
+
hostname: server.hostname,
|
27
|
+
endpoints: server.endpoints.apply((endpoints) => endpoints.map(l3EndpointToString))
|
28
|
+
},
|
29
|
+
$terminals: [createSshTerminal(server.ssh)]
|
30
|
+
});
|
31
|
+
export {
|
32
|
+
existing_server_default as default
|
33
|
+
};
|
34
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/units/existing-server/index.ts"],"sourcesContent":["import { common } from \"@highstate/library\"\nimport { forUnit, toPromise } from \"@highstate/pulumi\"\nimport {\n createServerEntity,\n createSshTerminal,\n l3EndpointToString,\n requireInputL3Endpoint,\n} from \"../../shared\"\n\nconst { name, args, inputs, secrets, outputs } = forUnit(common.existingServer)\n\nconst endpoint = await requireInputL3Endpoint(args.endpoint, inputs.endpoint)\nconst privateKey = await toPromise(inputs.sshKeyPair?.privateKey ?? secrets.sshPrivateKey)\n\nconst server = createServerEntity(\n name,\n endpoint,\n args.sshPort,\n args.sshUser,\n secrets.sshPassword,\n privateKey,\n)\n\nexport default outputs({\n server,\n endpoints: server.endpoints,\n\n $status: {\n hostname: server.hostname,\n endpoints: server.endpoints.apply(endpoints => endpoints.map(l3EndpointToString)),\n },\n\n $terminals: [createSshTerminal(server.ssh)],\n})\n"],"mappings":";;;;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,SAAS,iBAAiB;AAQnC,IAAM,EAAE,MAAM,MAAM,QAAQ,SAAS,QAAQ,IAAI,QAAQ,OAAO,cAAc;AAE9E,IAAM,WAAW,MAAM,uBAAuB,KAAK,UAAU,OAAO,QAAQ;AAC5E,IAAM,aAAa,MAAM,UAAU,OAAO,YAAY,cAAc,QAAQ,aAAa;AAEzF,IAAM,SAAS;AAAA,EACb;AAAA,EACA;AAAA,EACA,KAAK;AAAA,EACL,KAAK;AAAA,EACL,QAAQ;AAAA,EACR;AACF;AAEA,IAAO,0BAAQ,QAAQ;AAAA,EACrB;AAAA,EACA,WAAW,OAAO;AAAA,EAElB,SAAS;AAAA,IACP,UAAU,OAAO;AAAA,IACjB,WAAW,OAAO,UAAU,MAAM,eAAa,UAAU,IAAI,kBAAkB,CAAC;AAAA,EAClF;AAAA,EAEA,YAAY,CAAC,kBAAkB,OAAO,GAAG,CAAC;AAC5C,CAAC;","names":[]}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import {
|
2
|
+
parseL3Endpoint
|
3
|
+
} from "../../../chunk-USV6SHAU.js";
|
4
|
+
|
5
|
+
// src/units/network/l3-endpoint/index.ts
|
6
|
+
import { network } from "@highstate/library";
|
7
|
+
import { forUnit } from "@highstate/pulumi";
|
8
|
+
var { args, outputs } = forUnit(network.l3Endpoint);
|
9
|
+
var l3_endpoint_default = outputs({
|
10
|
+
endpoint: parseL3Endpoint(args.endpoint)
|
11
|
+
});
|
12
|
+
export {
|
13
|
+
l3_endpoint_default as default
|
14
|
+
};
|
15
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/units/network/l3-endpoint/index.ts"],"sourcesContent":["import { network } from \"@highstate/library\"\nimport { forUnit } from \"@highstate/pulumi\"\nimport { parseL3Endpoint } from \"../../../shared\"\n\nconst { args, outputs } = forUnit(network.l3Endpoint)\n\nexport default outputs({\n endpoint: parseL3Endpoint(args.endpoint),\n})\n"],"mappings":";;;;;AAAA,SAAS,eAAe;AACxB,SAAS,eAAe;AAGxB,IAAM,EAAE,MAAM,QAAQ,IAAI,QAAQ,QAAQ,UAAU;AAEpD,IAAO,sBAAQ,QAAQ;AAAA,EACrB,UAAU,gBAAgB,KAAK,QAAQ;AACzC,CAAC;","names":[]}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import {
|
2
|
+
parseL4Endpoint
|
3
|
+
} from "../../../chunk-USV6SHAU.js";
|
4
|
+
|
5
|
+
// src/units/network/l4-endpoint/index.ts
|
6
|
+
import { network } from "@highstate/library";
|
7
|
+
import { forUnit } from "@highstate/pulumi";
|
8
|
+
var { args, outputs } = forUnit(network.l4Endpoint);
|
9
|
+
var l4_endpoint_default = outputs({
|
10
|
+
endpoint: parseL4Endpoint(args.endpoint)
|
11
|
+
});
|
12
|
+
export {
|
13
|
+
l4_endpoint_default as default
|
14
|
+
};
|
15
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/units/network/l4-endpoint/index.ts"],"sourcesContent":["import { network } from \"@highstate/library\"\nimport { forUnit } from \"@highstate/pulumi\"\nimport { parseL4Endpoint } from \"../../../shared\"\n\nconst { args, outputs } = forUnit(network.l4Endpoint)\n\nexport default outputs({\n endpoint: parseL4Endpoint(args.endpoint),\n})\n"],"mappings":";;;;;AAAA,SAAS,eAAe;AACxB,SAAS,eAAe;AAGxB,IAAM,EAAE,MAAM,QAAQ,IAAI,QAAQ,QAAQ,UAAU;AAEpD,IAAO,sBAAQ,QAAQ;AAAA,EACrB,UAAU,gBAAgB,KAAK,QAAQ;AACzC,CAAC;","names":[]}
|
@@ -1,14 +1,13 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
} from "
|
2
|
+
Command
|
3
|
+
} from "../../chunk-USV6SHAU.js";
|
4
4
|
|
5
|
-
// src/script/index.ts
|
5
|
+
// src/units/script/index.ts
|
6
6
|
import { common } from "@highstate/library";
|
7
7
|
import { forUnit } from "@highstate/pulumi";
|
8
8
|
var { name, args, inputs, outputs } = forUnit(common.script);
|
9
|
-
|
10
|
-
server
|
11
|
-
id: name,
|
9
|
+
new Command(name, {
|
10
|
+
host: inputs.server,
|
12
11
|
create: args.script,
|
13
12
|
update: args.updateScript,
|
14
13
|
delete: args.deleteScript
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/units/script/index.ts"],"sourcesContent":["import { common } from \"@highstate/library\"\nimport { forUnit } from \"@highstate/pulumi\"\nimport { Command } from \"../../shared\"\n\nconst { name, args, inputs, outputs } = forUnit(common.script)\n\nnew Command(name, {\n host: inputs.server,\n create: args.script,\n update: args.updateScript,\n delete: args.deleteScript,\n})\n\nexport default outputs({\n server: inputs.server,\n})\n"],"mappings":";;;;;AAAA,SAAS,cAAc;AACvB,SAAS,eAAe;AAGxB,IAAM,EAAE,MAAM,MAAM,QAAQ,QAAQ,IAAI,QAAQ,OAAO,MAAM;AAE7D,IAAI,QAAQ,MAAM;AAAA,EAChB,MAAM,OAAO;AAAA,EACb,QAAQ,KAAK;AAAA,EACb,QAAQ,KAAK;AAAA,EACb,QAAQ,KAAK;AACf,CAAC;AAED,IAAO,iBAAQ,QAAQ;AAAA,EACrB,QAAQ,OAAO;AACjB,CAAC;","names":[]}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import {
|
2
|
+
l3EndpointToString,
|
3
|
+
updateEndpointsWithFqdn
|
4
|
+
} from "../../chunk-USV6SHAU.js";
|
5
|
+
|
6
|
+
// src/units/server-dns/index.ts
|
7
|
+
import { common } from "@highstate/library";
|
8
|
+
import { forUnit } from "@highstate/pulumi";
|
9
|
+
var { args, inputs, outputs } = forUnit(common.serverDns);
|
10
|
+
var { endpoints } = await updateEndpointsWithFqdn(
|
11
|
+
inputs.server.endpoints,
|
12
|
+
args.fqdn,
|
13
|
+
args.endpointFilter,
|
14
|
+
args.patchMode,
|
15
|
+
inputs.dnsProviders
|
16
|
+
);
|
17
|
+
var server_dns_default = outputs({
|
18
|
+
server: inputs.server.apply((server) => ({
|
19
|
+
...server,
|
20
|
+
endpoints
|
21
|
+
})),
|
22
|
+
endpoints,
|
23
|
+
$status: {
|
24
|
+
endpoints: endpoints.map(l3EndpointToString)
|
25
|
+
}
|
26
|
+
});
|
27
|
+
export {
|
28
|
+
server_dns_default as default
|
29
|
+
};
|
30
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/units/server-dns/index.ts"],"sourcesContent":["import { common } from \"@highstate/library\"\nimport { forUnit } from \"@highstate/pulumi\"\nimport { l3EndpointToString, updateEndpointsWithFqdn } from \"../../shared\"\n\nconst { args, inputs, outputs } = forUnit(common.serverDns)\n\nconst { endpoints } = await updateEndpointsWithFqdn(\n inputs.server.endpoints,\n args.fqdn,\n args.endpointFilter,\n args.patchMode,\n inputs.dnsProviders,\n)\n\nexport default outputs({\n server: inputs.server.apply(server => ({\n ...server,\n endpoints,\n })),\n\n endpoints,\n\n $status: {\n endpoints: endpoints.map(l3EndpointToString),\n },\n})\n"],"mappings":";;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,eAAe;AAGxB,IAAM,EAAE,MAAM,QAAQ,QAAQ,IAAI,QAAQ,OAAO,SAAS;AAE1D,IAAM,EAAE,UAAU,IAAI,MAAM;AAAA,EAC1B,OAAO,OAAO;AAAA,EACd,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,OAAO;AACT;AAEA,IAAO,qBAAQ,QAAQ;AAAA,EACrB,QAAQ,OAAO,OAAO,MAAM,aAAW;AAAA,IACrC,GAAG;AAAA,IACH;AAAA,EACF,EAAE;AAAA,EAEF;AAAA,EAEA,SAAS;AAAA,IACP,WAAW,UAAU,IAAI,kBAAkB;AAAA,EAC7C;AACF,CAAC;","names":[]}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import {
|
2
|
+
l3EndpointToString,
|
3
|
+
updateEndpoints
|
4
|
+
} from "../../chunk-USV6SHAU.js";
|
5
|
+
|
6
|
+
// src/units/server-patch/index.ts
|
7
|
+
import { common } from "@highstate/library";
|
8
|
+
import { forUnit } from "@highstate/pulumi";
|
9
|
+
var { args, inputs, outputs } = forUnit(common.serverPatch);
|
10
|
+
var endpoints = await updateEndpoints(
|
11
|
+
inputs.server.endpoints,
|
12
|
+
args.endpoints,
|
13
|
+
inputs.endpoints,
|
14
|
+
args.endpointsPatchMode
|
15
|
+
);
|
16
|
+
var server_patch_default = outputs({
|
17
|
+
server: inputs.server.apply((server) => ({
|
18
|
+
...server,
|
19
|
+
endpoints
|
20
|
+
})),
|
21
|
+
endpoints,
|
22
|
+
$status: {
|
23
|
+
endpoints: endpoints.map(l3EndpointToString)
|
24
|
+
}
|
25
|
+
});
|
26
|
+
export {
|
27
|
+
server_patch_default as default
|
28
|
+
};
|
29
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/units/server-patch/index.ts"],"sourcesContent":["import { common } from \"@highstate/library\"\nimport { forUnit } from \"@highstate/pulumi\"\nimport { l3EndpointToString, updateEndpoints } from \"../../shared\"\n\nconst { args, inputs, outputs } = forUnit(common.serverPatch)\n\nconst endpoints = await updateEndpoints(\n inputs.server.endpoints,\n args.endpoints,\n inputs.endpoints,\n args.endpointsPatchMode,\n)\n\nexport default outputs({\n server: inputs.server.apply(server => ({\n ...server,\n endpoints,\n })),\n\n endpoints,\n\n $status: {\n endpoints: endpoints.map(l3EndpointToString),\n },\n})\n"],"mappings":";;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,eAAe;AAGxB,IAAM,EAAE,MAAM,QAAQ,QAAQ,IAAI,QAAQ,OAAO,WAAW;AAE5D,IAAM,YAAY,MAAM;AAAA,EACtB,OAAO,OAAO;AAAA,EACd,KAAK;AAAA,EACL,OAAO;AAAA,EACP,KAAK;AACP;AAEA,IAAO,uBAAQ,QAAQ;AAAA,EACrB,QAAQ,OAAO,OAAO,MAAM,aAAW;AAAA,IACrC,GAAG;AAAA,IACH;AAAA,EACF,EAAE;AAAA,EAEF;AAAA,EAEA,SAAS;AAAA,IACP,WAAW,UAAU,IAAI,kBAAkB;AAAA,EAC7C;AACF,CAAC;","names":[]}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import {
|
2
|
+
generatePrivateKey,
|
3
|
+
privateKeyToKeyPair
|
4
|
+
} from "../../../chunk-USV6SHAU.js";
|
5
|
+
|
6
|
+
// src/units/ssh/key-pair/index.ts
|
7
|
+
import { ssh } from "@highstate/library";
|
8
|
+
import { forUnit, getOrCreateSecret } from "@highstate/pulumi";
|
9
|
+
var { secrets, outputs } = forUnit(ssh.keyPair);
|
10
|
+
var privateKey = getOrCreateSecret(secrets, "privateKey", generatePrivateKey);
|
11
|
+
var keyPair = privateKeyToKeyPair(privateKey);
|
12
|
+
var key_pair_default = outputs({
|
13
|
+
keyPair: privateKeyToKeyPair(privateKey),
|
14
|
+
$status: {
|
15
|
+
fingerprint: keyPair.fingerprint,
|
16
|
+
publicKey: keyPair.publicKey
|
17
|
+
}
|
18
|
+
});
|
19
|
+
export {
|
20
|
+
key_pair_default as default
|
21
|
+
};
|
22
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../src/units/ssh/key-pair/index.ts"],"sourcesContent":["import { ssh } from \"@highstate/library\"\nimport { forUnit, getOrCreateSecret } from \"@highstate/pulumi\"\nimport { generatePrivateKey, privateKeyToKeyPair } from \"../../../shared\"\n\nconst { secrets, outputs } = forUnit(ssh.keyPair)\n\nconst privateKey = getOrCreateSecret(secrets, \"privateKey\", generatePrivateKey)\nconst keyPair = privateKeyToKeyPair(privateKey)\n\nexport default outputs({\n keyPair: privateKeyToKeyPair(privateKey),\n $status: {\n fingerprint: keyPair.fingerprint,\n publicKey: keyPair.publicKey,\n },\n})\n"],"mappings":";;;;;;AAAA,SAAS,WAAW;AACpB,SAAS,SAAS,yBAAyB;AAG3C,IAAM,EAAE,SAAS,QAAQ,IAAI,QAAQ,IAAI,OAAO;AAEhD,IAAM,aAAa,kBAAkB,SAAS,cAAc,kBAAkB;AAC9E,IAAM,UAAU,oBAAoB,UAAU;AAE9C,IAAO,mBAAQ,QAAQ;AAAA,EACrB,SAAS,oBAAoB,UAAU;AAAA,EACvC,SAAS;AAAA,IACP,aAAa,QAAQ;AAAA,IACrB,WAAW,QAAQ;AAAA,EACrB;AACF,CAAC;","names":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@highstate/common",
|
3
|
-
"version": "0.9.
|
3
|
+
"version": "0.9.6",
|
4
4
|
"type": "module",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -11,10 +11,14 @@
|
|
11
11
|
"types": "./src/index.ts",
|
12
12
|
"default": "./dist/index.js"
|
13
13
|
},
|
14
|
-
"./dns/record": "./dist/dns/record/index.js",
|
15
|
-
"./
|
16
|
-
"./
|
17
|
-
"./
|
14
|
+
"./units/dns/record-set": "./dist/units/dns/record-set/index.js",
|
15
|
+
"./units/network/l3-endpoint": "./dist/units/network/l3-endpoint/index.js",
|
16
|
+
"./units/network/l4-endpoint": "./dist/units/network/l4-endpoint/index.js",
|
17
|
+
"./units/existing-server": "./dist/units/existing-server/index.js",
|
18
|
+
"./units/ssh/key-pair": "./dist/units/ssh/key-pair/index.js",
|
19
|
+
"./units/script": "./dist/units/script/index.js",
|
20
|
+
"./units/server-dns": "./dist/units/server-dns/index.js",
|
21
|
+
"./units/server-patch": "./dist/units/server-patch/index.js"
|
18
22
|
},
|
19
23
|
"publishConfig": {
|
20
24
|
"access": "public"
|
@@ -23,14 +27,15 @@
|
|
23
27
|
"build": "highstate build"
|
24
28
|
},
|
25
29
|
"dependencies": {
|
26
|
-
"@highstate/library": "^0.9.
|
27
|
-
"@highstate/pulumi": "^0.9.
|
30
|
+
"@highstate/library": "^0.9.6",
|
31
|
+
"@highstate/pulumi": "^0.9.6",
|
28
32
|
"@noble/hashes": "^1.7.1",
|
29
33
|
"@pulumi/command": "^1.0.2",
|
30
|
-
"micro-key-producer": "^0.7.3"
|
34
|
+
"micro-key-producer": "^0.7.3",
|
35
|
+
"remeda": "^2.21.0"
|
31
36
|
},
|
32
37
|
"devDependencies": {
|
33
|
-
"@highstate/cli": "^0.9.
|
38
|
+
"@highstate/cli": "^0.9.6"
|
34
39
|
},
|
35
|
-
"gitHead": "
|
40
|
+
"gitHead": "3c7e8883ef6cbc3e3f7c2c5529115767aae5c96a"
|
36
41
|
}
|
@@ -0,0 +1,132 @@
|
|
1
|
+
import { local, remote, type types } from "@pulumi/command"
|
2
|
+
import {
|
3
|
+
ComponentResource,
|
4
|
+
interpolate,
|
5
|
+
output,
|
6
|
+
type ComponentResourceOptions,
|
7
|
+
type Input,
|
8
|
+
type InputOrArray,
|
9
|
+
type Output,
|
10
|
+
} from "@highstate/pulumi"
|
11
|
+
import { common, ssh } from "@highstate/library"
|
12
|
+
import { l3EndpointToString } from "./network"
|
13
|
+
|
14
|
+
export function getServerConnection(
|
15
|
+
ssh: Input<ssh.Credentials>,
|
16
|
+
): Output<types.input.remote.ConnectionArgs> {
|
17
|
+
return output(ssh).apply(ssh => ({
|
18
|
+
host: l3EndpointToString(ssh.endpoints[0]),
|
19
|
+
port: ssh.endpoints[0].port,
|
20
|
+
user: ssh.user,
|
21
|
+
password: ssh.password,
|
22
|
+
privateKey: ssh.keyPair?.privateKey,
|
23
|
+
dialErrorLimit: 3,
|
24
|
+
hostKey: ssh.hostKey,
|
25
|
+
}))
|
26
|
+
}
|
27
|
+
|
28
|
+
export type CommandHost = "local" | common.Server
|
29
|
+
|
30
|
+
export type CommandArgs = {
|
31
|
+
host: Input<CommandHost>
|
32
|
+
create: Input<string>
|
33
|
+
update?: Input<string>
|
34
|
+
delete?: Input<string>
|
35
|
+
logging?: Input<remote.Logging>
|
36
|
+
triggers?: InputOrArray<unknown>
|
37
|
+
}
|
38
|
+
|
39
|
+
export type TextFileArgs = {
|
40
|
+
host: CommandHost
|
41
|
+
path: Input<string>
|
42
|
+
content: Input<string>
|
43
|
+
}
|
44
|
+
|
45
|
+
export class Command extends ComponentResource {
|
46
|
+
public readonly command: Output<local.Command | remote.Command>
|
47
|
+
|
48
|
+
public readonly stdout: Output<string>
|
49
|
+
public readonly stderr: Output<string>
|
50
|
+
|
51
|
+
constructor(name: string, args: CommandArgs, opts?: ComponentResourceOptions) {
|
52
|
+
super("highstate:common:Command", name, args, opts)
|
53
|
+
|
54
|
+
this.command = output(args).apply(args => {
|
55
|
+
if (args.host === "local") {
|
56
|
+
return new local.Command(
|
57
|
+
name,
|
58
|
+
{
|
59
|
+
create: args.create,
|
60
|
+
update: args.update,
|
61
|
+
delete: args.delete,
|
62
|
+
logging: args.logging,
|
63
|
+
triggers: args.triggers,
|
64
|
+
},
|
65
|
+
{ ...opts, parent: this },
|
66
|
+
)
|
67
|
+
}
|
68
|
+
|
69
|
+
if (!args.host.ssh) {
|
70
|
+
throw new Error(`The host "${args.host.hostname}" has no SSH credentials`)
|
71
|
+
}
|
72
|
+
|
73
|
+
return new remote.Command(
|
74
|
+
name,
|
75
|
+
{
|
76
|
+
connection: getServerConnection(args.host.ssh),
|
77
|
+
create: args.create,
|
78
|
+
update: args.update,
|
79
|
+
delete: args.delete,
|
80
|
+
logging: args.logging,
|
81
|
+
triggers: args.triggers,
|
82
|
+
},
|
83
|
+
{ ...opts, parent: this },
|
84
|
+
)
|
85
|
+
})
|
86
|
+
|
87
|
+
this.stdout = this.command.stdout
|
88
|
+
this.stderr = this.command.stderr
|
89
|
+
}
|
90
|
+
|
91
|
+
static createTextFile(
|
92
|
+
name: string,
|
93
|
+
options: TextFileArgs,
|
94
|
+
opts?: ComponentResourceOptions,
|
95
|
+
): Output<Command> {
|
96
|
+
return output(options).apply(options => {
|
97
|
+
const escapedContent = options.content.replace(/"/g, '\\"')
|
98
|
+
|
99
|
+
const command = new Command(
|
100
|
+
name,
|
101
|
+
{
|
102
|
+
host: options.host,
|
103
|
+
create: interpolate`mkdir -p $(dirname ${options.path}) && echo "${escapedContent}" > ${options.path}`,
|
104
|
+
delete: interpolate`rm -rf ${options.path}`,
|
105
|
+
},
|
106
|
+
opts,
|
107
|
+
)
|
108
|
+
|
109
|
+
return command
|
110
|
+
})
|
111
|
+
}
|
112
|
+
|
113
|
+
static receiveTextFile(
|
114
|
+
name: string,
|
115
|
+
options: Omit<TextFileArgs, "content">,
|
116
|
+
opts?: ComponentResourceOptions,
|
117
|
+
): Output<Command> {
|
118
|
+
return output(options).apply(options => {
|
119
|
+
const command = new Command(
|
120
|
+
name,
|
121
|
+
{
|
122
|
+
host: options.host,
|
123
|
+
create: interpolate`while ! test -f ${options.path}; do sleep 1; done; cat ${options.path}`,
|
124
|
+
logging: "stderr",
|
125
|
+
},
|
126
|
+
opts,
|
127
|
+
)
|
128
|
+
|
129
|
+
return command
|
130
|
+
})
|
131
|
+
}
|
132
|
+
}
|