@mrsimpson/homelab-core-components 0.2.4 → 0.2.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/app-namespace.d.ts.map +1 -1
- package/dist/app-namespace.js +3 -1
- package/dist/app-namespace.js.map +1 -1
- package/dist/postgres/PostgresInstance.d.ts +2 -2
- package/dist/postgres/PostgresInstance.d.ts.map +1 -1
- package/dist/postgres/PostgresInstance.js +6 -4
- package/dist/postgres/PostgresInstance.js.map +1 -1
- package/package.json +1 -1
- package/src/app-namespace.preview.test.ts +32 -0
- package/src/app-namespace.ts +10 -4
- package/src/postgres/PostgresInstance.test.ts +43 -0
- package/src/postgres/PostgresInstance.ts +8 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-namespace.d.ts","sourceRoot":"","sources":["../src/app-namespace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AACtD,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,eAAO,MAAM,aAAa,oCAAoC,CAAC;AAC/D,eAAO,MAAM,UAAU;;;;CAA2E,CAAC;AAEnG;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,qBAAqB;;;
|
|
1
|
+
{"version":3,"file":"app-namespace.d.ts","sourceRoot":"","sources":["../src/app-namespace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AACtD,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,eAAO,MAAM,aAAa,oCAAoC,CAAC;AAC/D,eAAO,MAAM,UAAU;;;;CAA2E,CAAC;AAEnG;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,qBAAqB;;;EAqCnF"}
|
package/dist/app-namespace.js
CHANGED
|
@@ -72,7 +72,9 @@ function createAppNamespace(name, opts) {
|
|
|
72
72
|
roleRef: { apiGroup: "rbac.authorization.k8s.io", kind: "ClusterRole", name: exports.DEPLOYER_ROLE },
|
|
73
73
|
subjects: [exports.CI_SUBJECT],
|
|
74
74
|
}, { ...opts, dependsOn: [created] });
|
|
75
|
-
|
|
75
|
+
// The ID comes from binding.id, which is unknown until the RoleBinding really exists, so a
|
|
76
|
+
// preview of a first deploy does not try to read a namespace that is not there yet.
|
|
77
|
+
const namespace = k8s.core.v1.Namespace.get(`${name}-ns-ready`, binding.id.apply(() => name), {
|
|
76
78
|
...opts,
|
|
77
79
|
dependsOn: [binding],
|
|
78
80
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-namespace.js","sourceRoot":"","sources":["../src/app-namespace.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,
|
|
1
|
+
{"version":3,"file":"app-namespace.js","sourceRoot":"","sources":["../src/app-namespace.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,gDAqCC;AA3DD,wDAA0C;AAG1C;;;;GAIG;AACU,QAAA,mBAAmB,GAAG,kBAAkB,CAAC;AACzC,QAAA,mBAAmB,GAAG,cAAc,CAAC;AACrC,QAAA,aAAa,GAAG,iCAAiC,CAAC;AAClD,QAAA,UAAU,GAAG,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;AAEnG;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAAC,IAAY,EAAE,IAAmC;IAClF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CACvC,GAAG,IAAI,KAAK,EACZ;QACE,QAAQ,EAAE;YACR,IAAI;YACJ,MAAM,EAAE;gBACN,CAAC,2BAAmB,CAAC,EAAE,2BAAmB;gBAC1C,wBAAwB,EAAE,IAAI;gBAC9B,oCAAoC,EAAE,YAAY;gBAClD,kCAAkC,EAAE,YAAY;gBAChD,iCAAiC,EAAE,YAAY;aAChD;SACF;KACF,EACD,IAAI,CACL,CAAC;IACF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CACzC,GAAG,IAAI,WAAW,EAClB;QACE,QAAQ,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE,SAAS,EAAE,IAAI,EAAE;QAC5D,OAAO,EAAE,EAAE,QAAQ,EAAE,2BAA2B,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,qBAAa,EAAE;QAC5F,QAAQ,EAAE,CAAC,kBAAU,CAAC;KACvB,EACD,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,CAClC,CAAC;IACF,2FAA2F;IAC3F,oFAAoF;IACpF,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CACzC,GAAG,IAAI,WAAW,EAClB,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,EAC5B;QACE,GAAG,IAAI;QACP,SAAS,EAAE,CAAC,OAAO,CAAC;KACrB,CACF,CAAC;IACF,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -8,7 +8,7 @@ export interface PostgresInstanceArgs {
|
|
|
8
8
|
/**
|
|
9
9
|
* Container image for Postgres.
|
|
10
10
|
* Must start with the PG major version (e.g. `18`) — CNPG's webhook rejects `latest`.
|
|
11
|
-
* @default "
|
|
11
|
+
* @default "ghcr.io/cloudnative-pg/postgresql:18"
|
|
12
12
|
*/
|
|
13
13
|
image?: pulumi.Input<string>;
|
|
14
14
|
/** @default "app" — CNPG convention */
|
|
@@ -25,7 +25,7 @@ export interface PostgresInstanceArgs {
|
|
|
25
25
|
*/
|
|
26
26
|
instances?: number;
|
|
27
27
|
/**
|
|
28
|
-
* UID/GID for the postgres OS user.
|
|
28
|
+
* UID/GID for the postgres OS user. CNPG images use 26; the Docker Hub postgres image and paradedb use 999.
|
|
29
29
|
* **Immutable** — changing requires cluster deletion and recreation.
|
|
30
30
|
* @default 26
|
|
31
31
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresInstance.d.ts","sourceRoot":"","sources":["../../src/postgres/PostgresInstance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"PostgresInstance.d.ts","sourceRoot":"","sources":["../../src/postgres/PostgresInstance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAyBzC,MAAM,WAAW,oBAAoB;IACnC,sDAAsD;IACtD,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC;IAEjC,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEnC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE7B,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEhC,qBAAqB;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEnC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEpC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAElC;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAElC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;CAChC;AAED,qBAAa,gBAAiB,SAAQ,MAAM,CAAC,iBAAiB;IAC5D,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE5C,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAErC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAErC,gDAAgD;IAChD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEjD;;;;;;;OAOG;IACH,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAE1C,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,wBAAwB;CAyH7F"}
|
|
@@ -45,15 +45,17 @@ const pulumi = __importStar(require("@pulumi/pulumi"));
|
|
|
45
45
|
*
|
|
46
46
|
* See docs/howto/deploy-database.md for usage and the restore runbook.
|
|
47
47
|
*/
|
|
48
|
-
//
|
|
49
|
-
|
|
48
|
+
// CloudNativePG's own image: its postgres user has UID/GID 26, CNPG's default. The Docker Hub image
|
|
49
|
+
// (postgres:18) runs as 999, and initdb fails ("could not look up effective user ID 26").
|
|
50
|
+
// CNPG's webhook rejects tags that don't start with the PG major version (e.g. "latest-pg18").
|
|
51
|
+
const DEFAULT_IMAGE = "ghcr.io/cloudnative-pg/postgresql:18";
|
|
50
52
|
const DEFAULT_USERNAME = "app"; // CNPG convention: app user owns the app database
|
|
51
53
|
const DEFAULT_STORAGE_SIZE = "5Gi";
|
|
52
54
|
const DEFAULT_STORAGE_CLASS = "longhorn-persistent";
|
|
53
55
|
const DEFAULT_INSTANCES = 1;
|
|
54
56
|
const PG_PORT = 5432;
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
+
// UID/GID of the postgres user in CNPG's images. Override at call site for other images
|
|
58
|
+
// (the Docker Hub postgres image and paradedb use 999).
|
|
57
59
|
const DEFAULT_POSTGRES_UID = 26;
|
|
58
60
|
const DEFAULT_POSTGRES_GID = 26;
|
|
59
61
|
class PostgresInstance extends pulumi.ComponentResource {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresInstance.js","sourceRoot":"","sources":["../../src/postgres/PostgresInstance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0C;AAC1C,uDAAyC;AAEzC;;;;;;;;GAQG;AAEH,
|
|
1
|
+
{"version":3,"file":"PostgresInstance.js","sourceRoot":"","sources":["../../src/postgres/PostgresInstance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0C;AAC1C,uDAAyC;AAEzC;;;;;;;;GAQG;AAEH,oGAAoG;AACpG,0FAA0F;AAC1F,+FAA+F;AAC/F,MAAM,aAAa,GAAG,sCAAsC,CAAC;AAC7D,MAAM,gBAAgB,GAAG,KAAK,CAAC,CAAC,kDAAkD;AAClF,MAAM,oBAAoB,GAAG,KAAK,CAAC;AACnC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AACpD,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,wFAAwF;A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;aACzB;SACF,EACD,EAAE,GAAG,SAAS,EAAE,SAAS,EAAE,CAAC,UAAU,CAAC,EAAE,CAC1C,CAAC;QAEF,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAA,GAAG,WAAW,IAAI,aAAa,oBAAoB,CAAC;QAEnF,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC;QACnC,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAE9D,IAAI,CAAC,eAAe,CAAC;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;SAClD,CAAC,CAAC;IACL,CAAC;CACF;AA/ID,4CA+IC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as pulumi from "@pulumi/pulumi";
|
|
2
|
+
import { beforeAll, describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
// Preview of a first deploy: nothing exists yet. The namespace reference must not be read with
|
|
5
|
+
// a known ID (a read of a namespace that does not exist fails the whole preview). With an
|
|
6
|
+
// unknown ID the engine skips the read in a preview.
|
|
7
|
+
const reads: string[] = [];
|
|
8
|
+
|
|
9
|
+
beforeAll(async () => {
|
|
10
|
+
pulumi.runtime.setMocks(
|
|
11
|
+
{
|
|
12
|
+
newResource: (args) => {
|
|
13
|
+
if (args.id && args.id !== pulumi.runtime.unknownValue) reads.push(args.name);
|
|
14
|
+
// In a preview, resources to be created have no ID yet.
|
|
15
|
+
return { id: args.id ?? "", state: args.inputs };
|
|
16
|
+
},
|
|
17
|
+
call: (args) => args.inputs,
|
|
18
|
+
},
|
|
19
|
+
"app",
|
|
20
|
+
"test",
|
|
21
|
+
true
|
|
22
|
+
);
|
|
23
|
+
const { createAppNamespace } = await import("./app-namespace");
|
|
24
|
+
createAppNamespace("gitea");
|
|
25
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("createAppNamespace in a preview", () => {
|
|
29
|
+
it("does not read the namespace before the RoleBinding exists", () => {
|
|
30
|
+
expect(reads).toEqual([]);
|
|
31
|
+
});
|
|
32
|
+
});
|
package/src/app-namespace.ts
CHANGED
|
@@ -46,9 +46,15 @@ export function createAppNamespace(name: string, opts?: pulumi.CustomResourceOpt
|
|
|
46
46
|
},
|
|
47
47
|
{ ...opts, dependsOn: [created] }
|
|
48
48
|
);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
// The ID comes from binding.id, which is unknown until the RoleBinding really exists, so a
|
|
50
|
+
// preview of a first deploy does not try to read a namespace that is not there yet.
|
|
51
|
+
const namespace = k8s.core.v1.Namespace.get(
|
|
52
|
+
`${name}-ns-ready`,
|
|
53
|
+
binding.id.apply(() => name),
|
|
54
|
+
{
|
|
55
|
+
...opts,
|
|
56
|
+
dependsOn: [binding],
|
|
57
|
+
}
|
|
58
|
+
);
|
|
53
59
|
return { namespace, binding };
|
|
54
60
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as k8s from "@pulumi/kubernetes";
|
|
2
|
+
import * as pulumi from "@pulumi/pulumi";
|
|
3
|
+
import { beforeAll, describe, expect, it } from "vitest";
|
|
4
|
+
|
|
5
|
+
const created: Array<{ type: string; name: string; inputs: Record<string, unknown> }> = [];
|
|
6
|
+
|
|
7
|
+
beforeAll(async () => {
|
|
8
|
+
pulumi.runtime.setMocks(
|
|
9
|
+
{
|
|
10
|
+
newResource: (args) => {
|
|
11
|
+
created.push({ type: args.type, name: args.name, inputs: args.inputs });
|
|
12
|
+
// Secret.get (the CNPG-generated credentials) reads existing state: give it data.
|
|
13
|
+
const state =
|
|
14
|
+
args.id && args.type === "kubernetes:core/v1:Secret" ? { data: {} } : args.inputs;
|
|
15
|
+
return { id: args.id || `${args.name}-id`, state };
|
|
16
|
+
},
|
|
17
|
+
call: (args) => args.inputs,
|
|
18
|
+
},
|
|
19
|
+
"app",
|
|
20
|
+
"test",
|
|
21
|
+
false
|
|
22
|
+
);
|
|
23
|
+
const { PostgresInstance } = await import("./PostgresInstance");
|
|
24
|
+
const namespace = new k8s.core.v1.Namespace("gitea", { metadata: { name: "gitea" } });
|
|
25
|
+
new PostgresInstance("gitea-db", { namespace, databaseName: "gitea" });
|
|
26
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("PostgresInstance defaults", () => {
|
|
30
|
+
it("uses CloudNativePG's own image, whose postgres user has the default UID 26", () => {
|
|
31
|
+
const cluster = created.find((c) => c.type === "kubernetes:postgresql.cnpg.io/v1:Cluster");
|
|
32
|
+
const spec = cluster?.inputs.spec as {
|
|
33
|
+
imageName: string;
|
|
34
|
+
postgresUID: number;
|
|
35
|
+
postgresGID: number;
|
|
36
|
+
};
|
|
37
|
+
// The Docker Hub image (postgres:18) runs as UID 999: initdb fails with "could not look up
|
|
38
|
+
// effective user ID 26" (observed 2026-11-13, first app on this component: gitea).
|
|
39
|
+
expect(spec.imageName).toBe("ghcr.io/cloudnative-pg/postgresql:18");
|
|
40
|
+
expect(spec.postgresUID).toBe(26);
|
|
41
|
+
expect(spec.postgresGID).toBe(26);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -11,15 +11,17 @@ import * as pulumi from "@pulumi/pulumi";
|
|
|
11
11
|
* See docs/howto/deploy-database.md for usage and the restore runbook.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
//
|
|
15
|
-
|
|
14
|
+
// CloudNativePG's own image: its postgres user has UID/GID 26, CNPG's default. The Docker Hub image
|
|
15
|
+
// (postgres:18) runs as 999, and initdb fails ("could not look up effective user ID 26").
|
|
16
|
+
// CNPG's webhook rejects tags that don't start with the PG major version (e.g. "latest-pg18").
|
|
17
|
+
const DEFAULT_IMAGE = "ghcr.io/cloudnative-pg/postgresql:18";
|
|
16
18
|
const DEFAULT_USERNAME = "app"; // CNPG convention: app user owns the app database
|
|
17
19
|
const DEFAULT_STORAGE_SIZE = "5Gi";
|
|
18
20
|
const DEFAULT_STORAGE_CLASS = "longhorn-persistent";
|
|
19
21
|
const DEFAULT_INSTANCES = 1;
|
|
20
22
|
const PG_PORT = 5432;
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
+
// UID/GID of the postgres user in CNPG's images. Override at call site for other images
|
|
24
|
+
// (the Docker Hub postgres image and paradedb use 999).
|
|
23
25
|
const DEFAULT_POSTGRES_UID = 26;
|
|
24
26
|
const DEFAULT_POSTGRES_GID = 26;
|
|
25
27
|
export interface PostgresInstanceArgs {
|
|
@@ -32,7 +34,7 @@ export interface PostgresInstanceArgs {
|
|
|
32
34
|
/**
|
|
33
35
|
* Container image for Postgres.
|
|
34
36
|
* Must start with the PG major version (e.g. `18`) — CNPG's webhook rejects `latest`.
|
|
35
|
-
* @default "
|
|
37
|
+
* @default "ghcr.io/cloudnative-pg/postgresql:18"
|
|
36
38
|
*/
|
|
37
39
|
image?: pulumi.Input<string>;
|
|
38
40
|
|
|
@@ -54,7 +56,7 @@ export interface PostgresInstanceArgs {
|
|
|
54
56
|
instances?: number;
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
|
-
* UID/GID for the postgres OS user.
|
|
59
|
+
* UID/GID for the postgres OS user. CNPG images use 26; the Docker Hub postgres image and paradedb use 999.
|
|
58
60
|
* **Immutable** — changing requires cluster deletion and recreation.
|
|
59
61
|
* @default 26
|
|
60
62
|
*/
|