@r8s/recipes 0.2.1 → 0.3.1
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.d.ts +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +3 -6
- package/dist/app.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +6 -10
- package/dist/auth.js.map +1 -1
- package/dist/backup.d.ts +18 -2
- package/dist/backup.d.ts.map +1 -1
- package/dist/backup.js +54 -6
- package/dist/backup.js.map +1 -1
- package/dist/cert-provider.d.ts.map +1 -1
- package/dist/cert-provider.js +2 -5
- package/dist/cert-provider.js.map +1 -1
- package/dist/database.d.ts +43 -15
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +114 -23
- package/dist/database.js.map +1 -1
- package/dist/dns-provider.d.ts.map +1 -1
- package/dist/dns-provider.js +6 -6
- package/dist/dns-provider.js.map +1 -1
- package/dist/endpoint.d.ts.map +1 -1
- package/dist/endpoint.js +11 -20
- package/dist/endpoint.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -8
- package/dist/index.js.map +1 -1
- package/dist/monitoring.d.ts.map +1 -1
- package/dist/monitoring.js +6 -13
- package/dist/monitoring.js.map +1 -1
- package/dist/namespace.d.ts +41 -0
- package/dist/namespace.d.ts.map +1 -0
- package/dist/namespace.js +78 -0
- package/dist/namespace.js.map +1 -0
- package/dist/platform.d.ts +3 -2
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +7 -18
- package/dist/platform.js.map +1 -1
- package/dist/r8s-cluster.d.ts +1 -1
- package/dist/r8s-cluster.d.ts.map +1 -1
- package/dist/r8s-cluster.js +25 -16
- package/dist/r8s-cluster.js.map +1 -1
- package/dist/s3-provider.d.ts +151 -0
- package/dist/s3-provider.d.ts.map +1 -0
- package/dist/s3-provider.js +126 -0
- package/dist/s3-provider.js.map +1 -0
- package/dist/secret-provider.d.ts +6 -6
- package/dist/secret-provider.d.ts.map +1 -1
- package/dist/secret-provider.js +6 -9
- package/dist/secret-provider.js.map +1 -1
- package/dist/use-operators.d.ts +7 -0
- package/dist/use-operators.d.ts.map +1 -0
- package/dist/use-operators.js +13 -0
- package/dist/use-operators.js.map +1 -0
- package/dist/web-service.d.ts.map +1 -1
- package/dist/web-service.js +2 -5
- package/dist/web-service.js.map +1 -1
- package/package.json +30 -5
- package/dist/operators.d.ts +0 -33
- package/dist/operators.d.ts.map +0 -1
- package/dist/operators.js +0 -56
- package/dist/operators.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface NamespaceProps {
|
|
2
|
+
/** Namespace name — DNS-1123 label (lowercase alphanumerics and '-') */
|
|
3
|
+
name: string;
|
|
4
|
+
/**
|
|
5
|
+
* Emit the `v1/Namespace` resource so the rendered output is
|
|
6
|
+
* self-contained (kubectl apply / Flux creates the namespace as part of
|
|
7
|
+
* the same manifest). Default: true. Set false when the namespace is
|
|
8
|
+
* managed elsewhere (GitOps repo convention, existing tenant setup).
|
|
9
|
+
*/
|
|
10
|
+
create?: boolean;
|
|
11
|
+
/** Components scoped to this namespace */
|
|
12
|
+
children?: unknown;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Namespace scope — composable cluster partitioning.
|
|
16
|
+
*
|
|
17
|
+
* Everything below inherits the namespace: <App>, <Database>, <WebService>,
|
|
18
|
+
* <Endpoint>, <Auth>, <StaticSecret> and every app package read it through
|
|
19
|
+
* useNamespace(). Nest to partition a cluster — the innermost scope wins,
|
|
20
|
+
* explicit `namespace` props on a component still override the scope:
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { Platform, Namespace, App, Database } from '@r8s/recipes'
|
|
24
|
+
*
|
|
25
|
+
* export default (
|
|
26
|
+
* <Platform secrets={{ backend: 'openbao', mount: 'kv', path: 'apps' }}>
|
|
27
|
+
* <Namespace name="team-a">
|
|
28
|
+
* <App name="api" image="myorg/api:v1" host="api.example.com" />
|
|
29
|
+
* <Database name="api-db" backup={false} />
|
|
30
|
+
* </Namespace>
|
|
31
|
+
* <Namespace name="team-b">
|
|
32
|
+
* <App name="billing" image="myorg/billing:v2" host="billing.example.com" />
|
|
33
|
+
* </Namespace>
|
|
34
|
+
* </Platform>
|
|
35
|
+
* )
|
|
36
|
+
*
|
|
37
|
+
* @title Namespace
|
|
38
|
+
* @category Cluster Foundation
|
|
39
|
+
*/
|
|
40
|
+
export declare function Namespace(props: NamespaceProps): import("@r8s/core").r8sElement[];
|
|
41
|
+
//# sourceMappingURL=namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../src/namespace.tsx"],"names":[],"mappings":"AAaA,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAA;IACZ;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,oCA2C9C"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Namespace = Namespace;
|
|
4
|
+
const core_1 = require("@r8s/core");
|
|
5
|
+
// The raw context shares the component's name (same word, different module).
|
|
6
|
+
// The alias keeps this file unambiguous; users never see it — they write
|
|
7
|
+
// <Namespace name="…"> from @r8s/recipes or Namespace.Provider from core.
|
|
8
|
+
const defaults_1 = require("@r8s/core/defaults");
|
|
9
|
+
/**
|
|
10
|
+
* DNS-1123 label: lowercase alphanumeric or '-', start/end alphanumeric,
|
|
11
|
+
* max 63 chars (RFC 1123 — the constraint Kubernetes applies to namespace
|
|
12
|
+
* names).
|
|
13
|
+
*/
|
|
14
|
+
const DNS1123_LABEL = /^[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])?$/;
|
|
15
|
+
/**
|
|
16
|
+
* Namespace scope — composable cluster partitioning.
|
|
17
|
+
*
|
|
18
|
+
* Everything below inherits the namespace: <App>, <Database>, <WebService>,
|
|
19
|
+
* <Endpoint>, <Auth>, <StaticSecret> and every app package read it through
|
|
20
|
+
* useNamespace(). Nest to partition a cluster — the innermost scope wins,
|
|
21
|
+
* explicit `namespace` props on a component still override the scope:
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* import { Platform, Namespace, App, Database } from '@r8s/recipes'
|
|
25
|
+
*
|
|
26
|
+
* export default (
|
|
27
|
+
* <Platform secrets={{ backend: 'openbao', mount: 'kv', path: 'apps' }}>
|
|
28
|
+
* <Namespace name="team-a">
|
|
29
|
+
* <App name="api" image="myorg/api:v1" host="api.example.com" />
|
|
30
|
+
* <Database name="api-db" backup={false} />
|
|
31
|
+
* </Namespace>
|
|
32
|
+
* <Namespace name="team-b">
|
|
33
|
+
* <App name="billing" image="myorg/billing:v2" host="billing.example.com" />
|
|
34
|
+
* </Namespace>
|
|
35
|
+
* </Platform>
|
|
36
|
+
* )
|
|
37
|
+
*
|
|
38
|
+
* @title Namespace
|
|
39
|
+
* @category Cluster Foundation
|
|
40
|
+
*/
|
|
41
|
+
function Namespace(props) {
|
|
42
|
+
const { name, create = true, children } = props;
|
|
43
|
+
const ambient = (0, core_1.useContext)(defaults_1.Namespace);
|
|
44
|
+
// Guard the type as well as the shape: a non-string (e.g. `undefined` from a
|
|
45
|
+
// mistyped caller) would marshal through String() and could sneak past the
|
|
46
|
+
// regexp as a bogus literal.
|
|
47
|
+
if (typeof name !== 'string' || !DNS1123_LABEL.test(name)) {
|
|
48
|
+
const suggestion = typeof name === 'string'
|
|
49
|
+
? name
|
|
50
|
+
.toLowerCase()
|
|
51
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
52
|
+
.replace(/^-+|-+$/g, '')
|
|
53
|
+
.slice(0, 63) || 'my-namespace'
|
|
54
|
+
: 'my-namespace';
|
|
55
|
+
throw new Error(`Namespace "${String(name)}" is not a valid DNS-1123 label.\n` +
|
|
56
|
+
`\n` +
|
|
57
|
+
`Namespace names must be lowercase alphanumeric or '-', start and end\n` +
|
|
58
|
+
`with an alphanumeric, and be at most 63 characters.\n` +
|
|
59
|
+
`\n` +
|
|
60
|
+
`Fix: <Namespace name="${suggestion}" />`);
|
|
61
|
+
}
|
|
62
|
+
const scoped = (0, core_1.jsx)(defaults_1.Namespace.Provider, { value: name, children });
|
|
63
|
+
if (!create || ambient === name) {
|
|
64
|
+
// Opt-out, the always-existing 'default', or an enclosing scope with the
|
|
65
|
+
// same name already emits it — the renderer does not dedupe and Flux
|
|
66
|
+
// rejects duplicate resource ids.
|
|
67
|
+
return [scoped];
|
|
68
|
+
}
|
|
69
|
+
return [
|
|
70
|
+
(0, core_1.jsx)('Namespace', {
|
|
71
|
+
apiVersion: 'v1',
|
|
72
|
+
kind: 'Namespace',
|
|
73
|
+
metadata: { name },
|
|
74
|
+
}),
|
|
75
|
+
scoped,
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=namespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../src/namespace.tsx"],"names":[],"mappings":";;AAqDA,8BA2CC;AAhGD,oCAA2C;AAC3C,6EAA6E;AAC7E,yEAAyE;AACzE,0EAA0E;AAC1E,iDAAkE;AAElE;;;;GAIG;AACH,MAAM,aAAa,GAAG,sCAAsC,CAAA;AAgB5D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,SAAS,CAAC,KAAqB;IAC7C,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC/C,MAAM,OAAO,GAAG,IAAA,iBAAU,EAAC,oBAAgB,CAAC,CAAA;IAE5C,6EAA6E;IAC7E,2EAA2E;IAC3E,6BAA6B;IAC7B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1D,MAAM,UAAU,GACd,OAAO,IAAI,KAAK,QAAQ;YACtB,CAAC,CAAC,IAAI;iBACD,WAAW,EAAE;iBACb,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC;iBAC5B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;iBACvB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,cAAc;YACnC,CAAC,CAAC,cAAc,CAAA;QACpB,MAAM,IAAI,KAAK,CACb,cAAc,MAAM,CAAC,IAAI,CAAC,oCAAoC;YAC5D,IAAI;YACJ,wEAAwE;YACxE,uDAAuD;YACvD,IAAI;YACJ,yBAAyB,UAAU,MAAM,CAC5C,CAAA;IACH,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,UAAG,EAAC,oBAAgB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IAExE,IAAI,CAAC,MAAM,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAChC,yEAAyE;QACzE,qEAAqE;QACrE,kCAAkC;QAClC,OAAO,CAAC,MAAM,CAAC,CAAA;IACjB,CAAC;IAED,OAAO;QACL,IAAA,UAAG,EAAC,WAAW,EAAE;YACf,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,EAAE,IAAI,EAAE;SACnB,CAAC;QACF,MAAM;KACP,CAAA;AACH,CAAC"}
|
package/dist/platform.d.ts
CHANGED
|
@@ -86,7 +86,8 @@ export interface PlatformProps {
|
|
|
86
86
|
* )
|
|
87
87
|
*
|
|
88
88
|
* @example
|
|
89
|
-
* import { Platform, App, Database
|
|
89
|
+
* import { Platform, App, Database } from '@r8s/recipes'
|
|
90
|
+
* import { cnpgOperator } from '@r8s/operator-cnpg'
|
|
90
91
|
* import { operators } from '@r8s/crds'
|
|
91
92
|
*
|
|
92
93
|
* export default (
|
|
@@ -95,7 +96,7 @@ export interface PlatformProps {
|
|
|
95
96
|
* namespace="production"
|
|
96
97
|
* operators={[cnpgOperator(), operators['cert-manager']()]}
|
|
97
98
|
* >
|
|
98
|
-
* <Database name="app-db" storage="10Gi" />
|
|
99
|
+
* <Database backup={false} name="app-db" storage="10Gi" />
|
|
99
100
|
* <App name="api" image="myapp/api:v1" host="api.example.com" />
|
|
100
101
|
* </Platform>
|
|
101
102
|
* )
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAQnE,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,CAAA;AAE/C,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;;OAIG;IACH,aAAa,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACpD,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,+CAA+C;IAC/C,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;IACtB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,mBAAmB,CAAA;IAC7B;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,gBAAgB,CAAA;IACtB,uFAAuF;IACvF,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,WA8C5C"}
|
package/dist/platform.js
CHANGED
|
@@ -6,6 +6,7 @@ const defaults_1 = require("@r8s/core/defaults");
|
|
|
6
6
|
const secret_provider_1 = require("./secret-provider");
|
|
7
7
|
const dns_provider_1 = require("./dns-provider");
|
|
8
8
|
const endpoint_provider_1 = require("./endpoint-provider");
|
|
9
|
+
const namespace_1 = require("./namespace");
|
|
9
10
|
/**
|
|
10
11
|
* Platform — cluster-level configuration wrapper.
|
|
11
12
|
*
|
|
@@ -41,7 +42,8 @@ const endpoint_provider_1 = require("./endpoint-provider");
|
|
|
41
42
|
* )
|
|
42
43
|
*
|
|
43
44
|
* @example
|
|
44
|
-
* import { Platform, App, Database
|
|
45
|
+
* import { Platform, App, Database } from '@r8s/recipes'
|
|
46
|
+
* import { cnpgOperator } from '@r8s/operator-cnpg'
|
|
45
47
|
* import { operators } from '@r8s/crds'
|
|
46
48
|
*
|
|
47
49
|
* export default (
|
|
@@ -50,7 +52,7 @@ const endpoint_provider_1 = require("./endpoint-provider");
|
|
|
50
52
|
* namespace="production"
|
|
51
53
|
* operators={[cnpgOperator(), operators['cert-manager']()]}
|
|
52
54
|
* >
|
|
53
|
-
* <Database name="app-db" storage="10Gi" />
|
|
55
|
+
* <Database backup={false} name="app-db" storage="10Gi" />
|
|
54
56
|
* <App name="api" image="myapp/api:v1" host="api.example.com" />
|
|
55
57
|
* </Platform>
|
|
56
58
|
* )
|
|
@@ -79,20 +81,6 @@ const endpoint_provider_1 = require("./endpoint-provider");
|
|
|
79
81
|
function Platform(props) {
|
|
80
82
|
const { routing = 'ingress', gatewayClassName = 'eg', namespace, labels, operators, secrets, dns, children, } = props;
|
|
81
83
|
let result = children;
|
|
82
|
-
// Materialize the Namespace resource so rendered output is self-contained.
|
|
83
|
-
// Without this, every resource references a namespace that may not exist.
|
|
84
|
-
if (namespace) {
|
|
85
|
-
result = (0, core_1.jsx)(core_1.Fragment, {
|
|
86
|
-
children: [
|
|
87
|
-
(0, core_1.jsx)('Namespace', {
|
|
88
|
-
apiVersion: 'v1',
|
|
89
|
-
kind: 'Namespace',
|
|
90
|
-
metadata: { name: namespace },
|
|
91
|
-
}),
|
|
92
|
-
result,
|
|
93
|
-
],
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
84
|
// Apply DNS context via DnsProvider (inside SecretProvider so it can access secrets)
|
|
97
85
|
if (dns) {
|
|
98
86
|
result = (0, core_1.jsx)(dns_provider_1.DnsProvider, { provider: dns, children: result });
|
|
@@ -112,9 +100,10 @@ function Platform(props) {
|
|
|
112
100
|
if (labels) {
|
|
113
101
|
result = (0, core_1.jsx)(defaults_1.Labels.Provider, { value: labels, children: result });
|
|
114
102
|
}
|
|
115
|
-
// Apply namespace
|
|
103
|
+
// Apply namespace scope via the <Namespace> recipe — emits the v1/Namespace
|
|
104
|
+
// resource (self-contained output) and inherits the namespace to children.
|
|
116
105
|
if (namespace) {
|
|
117
|
-
result = (0, core_1.jsx)(
|
|
106
|
+
result = (0, core_1.jsx)(namespace_1.Namespace, { name: namespace, children: result });
|
|
118
107
|
}
|
|
119
108
|
return result;
|
|
120
109
|
}
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.tsx"],"names":[],"mappings":";;AA0IA,4BA8CC;AAxLD,oCAA+B;AAC/B,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,EAAE,CAAC,CAAA;IAChF,CAAC;IAED,uBAAuB;IACvB,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,GAAG,IAAA,UAAG,EAAC,iBAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IACpE,CAAC;IAED,4EAA4E;IAC5E,2EAA2E;IAC3E,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,GAAG,IAAA,UAAG,EAAC,qBAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IAChE,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/r8s-cluster.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export interface R8sClusterProps {
|
|
|
94
94
|
* dns={{ server: 'ns1.example.com', zone: 'example.com', tsigPath: 'dns/tsig' }}
|
|
95
95
|
* >
|
|
96
96
|
* <Platform namespace="production">
|
|
97
|
-
* <Database name="api-db" storage="20Gi" />
|
|
97
|
+
* <Database backup={false} name="api-db" storage="20Gi" />
|
|
98
98
|
* <App name="api" image="api:v1" host="api.example.com" />
|
|
99
99
|
* </Platform>
|
|
100
100
|
* </R8sCluster>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"r8s-cluster.d.ts","sourceRoot":"","sources":["../src/r8s-cluster.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"r8s-cluster.d.ts","sourceRoot":"","sources":["../src/r8s-cluster.tsx"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,OAAO,EAAE;QACP,0CAA0C;QAC1C,KAAK,EAAE,MAAM,CAAA;QACb,gEAAgE;QAChE,IAAI,EAAE,MAAM,CAAA;QACZ,uCAAuC;QACvC,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;IACD;;;;;OAKG;IACH,GAAG,EAAE;QACH,oDAAoD;QACpD,MAAM,EAAE,MAAM,CAAA;QACd,qCAAqC;QACrC,IAAI,EAAE,MAAM,CAAA;QACZ,kDAAkD;QAClD,QAAQ,EAAE,MAAM,CAAA;QAChB,sDAAsD;QACtD,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;IACD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;IACtB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,WA6KhD"}
|
package/dist/r8s-cluster.js
CHANGED
|
@@ -3,7 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.R8sCluster = R8sCluster;
|
|
4
4
|
const core_1 = require("@r8s/core");
|
|
5
5
|
const defaults_1 = require("@r8s/core/defaults");
|
|
6
|
-
const
|
|
6
|
+
const operator_cert_manager_1 = require("@r8s/operator-cert-manager");
|
|
7
|
+
const operator_external_dns_1 = require("@r8s/operator-external-dns");
|
|
8
|
+
const operator_envoy_gateway_1 = require("@r8s/operator-envoy-gateway");
|
|
9
|
+
const operator_vault_secrets_1 = require("@r8s/operator-vault-secrets");
|
|
10
|
+
const operator_prometheus_1 = require("@r8s/operator-prometheus");
|
|
11
|
+
const operator_loki_1 = require("@r8s/operator-loki");
|
|
12
|
+
const operator_logging_1 = require("@r8s/operator-logging");
|
|
7
13
|
const loki_1 = require("@r8s/crds/loki");
|
|
8
14
|
const logging_1 = require("@r8s/crds/logging");
|
|
9
15
|
const secret_provider_1 = require("./secret-provider");
|
|
@@ -42,7 +48,7 @@ const endpoint_provider_1 = require("./endpoint-provider");
|
|
|
42
48
|
* dns={{ server: 'ns1.example.com', zone: 'example.com', tsigPath: 'dns/tsig' }}
|
|
43
49
|
* >
|
|
44
50
|
* <Platform namespace="production">
|
|
45
|
-
* <Database name="api-db" storage="20Gi" />
|
|
51
|
+
* <Database backup={false} name="api-db" storage="20Gi" />
|
|
46
52
|
* <App name="api" image="api:v1" host="api.example.com" />
|
|
47
53
|
* </Platform>
|
|
48
54
|
* </R8sCluster>
|
|
@@ -56,21 +62,24 @@ function R8sCluster(props) {
|
|
|
56
62
|
// cnpg, keycloak) via their own logic.
|
|
57
63
|
const sharedOperators = (0, core_1.useContext)(defaults_1.OperatorContext);
|
|
58
64
|
const declared = [];
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// R8sCluster's standard stack — each operator package's factory + its
|
|
66
|
+
// OPERATOR_KEY (the name lives in the package, not here). Seeds the
|
|
67
|
+
// children's OperatorContext so they never re-declare.
|
|
68
|
+
const clusterStack = [
|
|
69
|
+
[operator_cert_manager_1.operatorFactory, operator_cert_manager_1.OPERATOR_KEY],
|
|
70
|
+
[operator_external_dns_1.operatorFactory, operator_external_dns_1.OPERATOR_KEY],
|
|
71
|
+
[operator_envoy_gateway_1.operatorFactory, operator_envoy_gateway_1.OPERATOR_KEY],
|
|
72
|
+
[operator_vault_secrets_1.operatorFactory, operator_vault_secrets_1.OPERATOR_KEY],
|
|
73
|
+
[operator_prometheus_1.operatorFactory, operator_prometheus_1.OPERATOR_KEY],
|
|
74
|
+
[operator_loki_1.operatorFactory, operator_loki_1.OPERATOR_KEY],
|
|
75
|
+
[operator_logging_1.operatorFactory, operator_logging_1.OPERATOR_KEY],
|
|
67
76
|
];
|
|
68
|
-
for (const
|
|
69
|
-
const alreadyDeclared = sharedOperators.some((op) => op.name ===
|
|
70
|
-
preinstalled.some((op) => op.name ===
|
|
71
|
-
declared.some((op) => op.name ===
|
|
72
|
-
if (!alreadyDeclared
|
|
73
|
-
declared.push(
|
|
77
|
+
for (const [factory, key] of clusterStack) {
|
|
78
|
+
const alreadyDeclared = sharedOperators.some((op) => op.name === key) ||
|
|
79
|
+
preinstalled.some((op) => op.name === key) ||
|
|
80
|
+
declared.some((op) => op.name === key);
|
|
81
|
+
if (!alreadyDeclared) {
|
|
82
|
+
declared.push(factory());
|
|
74
83
|
}
|
|
75
84
|
}
|
|
76
85
|
// Build the secrets provider (OpenBao VSO)
|
package/dist/r8s-cluster.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"r8s-cluster.js","sourceRoot":"","sources":["../src/r8s-cluster.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"r8s-cluster.js","sourceRoot":"","sources":["../src/r8s-cluster.tsx"],"names":[],"mappings":";;AAyIA,gCA6KC;AAtTD,oCAAqD;AACrD,iDAA4D;AAC5D,sEAGmC;AACnC,sEAGmC;AACnC,wEAGoC;AACpC,wEAGoC;AACpC,kEAGiC;AACjC,sDAA6F;AAC7F,4DAG8B;AAC9B,yCAAmD;AACnD,+CAAoF;AACpF,uDAA2D;AAC3D,iDAAyD;AACzD,2DAAoE;AAkEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,SAAgB,UAAU,CAAC,KAAsB;IAC/C,MAAM,EACJ,OAAO,EACP,GAAG,EACH,gBAAgB,GAAG,IAAI,EACvB,MAAM,EACN,SAAS,EAAE,YAAY,GAAG,EAAE,EAC5B,aAAa,GAAG,SAAS,EACzB,gBAAgB,GAAG,UAAU,EAC7B,QAAQ,GACT,GAAG,KAAK,CAAA;IAET,sEAAsE;IACtE,mEAAmE;IACnE,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UAAG,EAAC,eAAQ,EAAE;QACrB,QAAQ,EAAE,CAAC,GAAG,gBAAgB,EAAE,MAAM,CAAC;KACxC,CAAC,CAAA;IAEF,yEAAyE;IACzE,MAAM,GAAG,IAAA,UAAG,EAAC,0BAAW,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IAEtE,sCAAsC;IACtC,MAAM,GAAG,IAAA,UAAG,EAAC,gCAAc,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IAE5E,wCAAwC;IACxC,MAAM,GAAG,IAAA,UAAG,EAAC,oCAAgB,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IAEhF,6EAA6E;IAC7E,MAAM,YAAY,GAAG,CAAC,GAAG,eAAe,EAAE,GAAG,YAAY,EAAE,GAAG,QAAQ,CAAC,CAAA;IACvE,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,GAAG,IAAA,UAAG,EAAC,0BAAe,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IACnF,CAAC;IAED,uBAAuB;IACvB,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,GAAG,IAAA,UAAG,EAAC,iBAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IACpE,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S3 capability — the platform's single source of object-storage truth.
|
|
3
|
+
*
|
|
4
|
+
* The provider publishes ONLY a store interface (which S3 is in play:
|
|
5
|
+
* MinIO, RustFS, AWS, …) plus the generic scoping descriptor. Consumers
|
|
6
|
+
* (Velero, CNPG, app packages) read it via useS3()/useContext and own
|
|
7
|
+
* their own conventions — prefix layout, credential keys, WAL archives.
|
|
8
|
+
* Nothing here knows which subsystems exist downstream.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Shared S3 (or S3-compatible) object storage configuration.
|
|
12
|
+
*
|
|
13
|
+
* `credentialsSecret` lives in each consumer's namespace and carries the
|
|
14
|
+
* keys that consumer's convention requires.
|
|
15
|
+
*/
|
|
16
|
+
export interface S3Config {
|
|
17
|
+
/** Endpoint URL incl. scheme (e.g. 'https://s3.example.com') */
|
|
18
|
+
endpoint: string;
|
|
19
|
+
/** Bucket holding all consumer prefixes */
|
|
20
|
+
bucket: string;
|
|
21
|
+
/** Region (default: 'us-east-1' — the convention for MinIO/RustFS) */
|
|
22
|
+
region?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Path-style addressing (default: true — virtually every non-AWS store
|
|
25
|
+
* requires it; AWS sets it via the AwsS3 convenience component)
|
|
26
|
+
*/
|
|
27
|
+
forcePathStyle?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Existing Secret holding the access keys. Must live in each
|
|
30
|
+
* consumer's namespace; the consumer decides which keys to read.
|
|
31
|
+
*/
|
|
32
|
+
credentialsSecret: string;
|
|
33
|
+
/**
|
|
34
|
+
* Optional path prefix scoping every consumer destination inside the
|
|
35
|
+
* bucket (set via <Bucket name="…"> — one path segment, no slashes).
|
|
36
|
+
*/
|
|
37
|
+
prefix?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* MinIO / RustFS convenience config — path style on, region default.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* import { S3Provider, MinIO } from '@r8s/recipes'
|
|
44
|
+
*
|
|
45
|
+
* export default (
|
|
46
|
+
* <S3Provider provider={<MinIO endpoint="https://rustfs:9000" bucket="infra" credentialsSecret="infra-s3-creds" />}>
|
|
47
|
+
* …consumers read the context…
|
|
48
|
+
* </S3Provider>
|
|
49
|
+
* )
|
|
50
|
+
*/
|
|
51
|
+
export interface MinIOProps {
|
|
52
|
+
endpoint: string;
|
|
53
|
+
bucket: string;
|
|
54
|
+
credentialsSecret: string;
|
|
55
|
+
region?: string;
|
|
56
|
+
}
|
|
57
|
+
export declare function MinIO(props: MinIOProps): S3Config;
|
|
58
|
+
/**
|
|
59
|
+
* AWS S3 convenience config — virtual-hosted style, endpoint derived from region.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* import { S3Provider, AwsS3 } from '@r8s/recipes'
|
|
63
|
+
*
|
|
64
|
+
* export default (
|
|
65
|
+
* <S3Provider provider={<AwsS3 region="eu-north-1" bucket="infra-backups" credentialsSecret="aws-creds" />}>
|
|
66
|
+
* …consumers read the context…
|
|
67
|
+
* </S3Provider>
|
|
68
|
+
* )
|
|
69
|
+
*/
|
|
70
|
+
export interface AwsS3Props {
|
|
71
|
+
region: string;
|
|
72
|
+
bucket: string;
|
|
73
|
+
credentialsSecret: string;
|
|
74
|
+
endpoint?: string;
|
|
75
|
+
}
|
|
76
|
+
export declare function AwsS3(props: AwsS3Props): S3Config;
|
|
77
|
+
export declare const S3Context: import("../../core/src/context").Context<S3Config | null>;
|
|
78
|
+
/** Read the surrounding S3 configuration (null when no provider is set). */
|
|
79
|
+
export declare function useS3(): S3Config | null;
|
|
80
|
+
export interface S3ProviderProps {
|
|
81
|
+
/**
|
|
82
|
+
* S3 configuration — the plain config object, or choose the convenience
|
|
83
|
+
* components <MinIO /> / <AwsS3 /> which are themselves S3Config values.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* <S3Provider provider={{ endpoint: 'https://s3.example.com', bucket: 'infra', credentialsSecret: 's3-creds' }}>
|
|
87
|
+
* <Database name="api-db" backup />
|
|
88
|
+
* </S3Provider>
|
|
89
|
+
*/
|
|
90
|
+
provider: S3Config;
|
|
91
|
+
/** Child components */
|
|
92
|
+
children?: unknown;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* S3Provider — publishes the platform's object store on context.
|
|
96
|
+
*
|
|
97
|
+
* Consumers resolve their own destinations from useS3(); <Bucket>
|
|
98
|
+
* scopes them; explicit per-consumer values always win.
|
|
99
|
+
*/
|
|
100
|
+
export declare function S3Provider(props: S3ProviderProps): import("@r8s/core").r8sElement;
|
|
101
|
+
export interface BucketProps {
|
|
102
|
+
/** Prefix segment under the bucket (single path segment, no slashes) */
|
|
103
|
+
name: string;
|
|
104
|
+
/** Point at another bucket than the surrounding provider's (isolates tenant prefixes) */
|
|
105
|
+
bucket?: string;
|
|
106
|
+
/** Point at another endpoint than the surrounding provider's */
|
|
107
|
+
endpoint?: string;
|
|
108
|
+
/** Point at another credentials Secret than the surrounding provider's */
|
|
109
|
+
credentialsSecret?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Bucket — a declarative pointer at an S3 destination to pass into
|
|
113
|
+
* consumers' backup/bucket props:
|
|
114
|
+
*
|
|
115
|
+
* <Database name="api-db" backup={<Bucket name="matrix_backup" />} />
|
|
116
|
+
*
|
|
117
|
+
* Endpoint/credentials resolve from the surrounding S3Provider unless the
|
|
118
|
+
* descriptor overrides them, so the call site shows exactly where data
|
|
119
|
+
* goes without repeating store config. Consumers append their own
|
|
120
|
+
* conventional suffix (`-cnpg`, `velero`, …).
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* import { S3Provider, MinIO, Bucket, Database, Backup } from '@r8s/recipes'
|
|
124
|
+
*
|
|
125
|
+
* export default (
|
|
126
|
+
* <S3Provider provider={<MinIO endpoint="https://rustfs:9000" bucket="infra" credentialsSecret="infra-s3-creds" />}>
|
|
127
|
+
* <Database name="matrix-db" backup={<Bucket name="matrix_backup" />} />
|
|
128
|
+
* </S3Provider>
|
|
129
|
+
* )
|
|
130
|
+
*/
|
|
131
|
+
export declare function Bucket(props: BucketProps): void;
|
|
132
|
+
export interface ResolvedBucket {
|
|
133
|
+
/** Effective store config after descriptor overrides */
|
|
134
|
+
s3: S3Config;
|
|
135
|
+
/** Prefix under the bucket the consumer composes with */
|
|
136
|
+
prefix: string;
|
|
137
|
+
/** Destination root including prefix (no consumer suffix) */
|
|
138
|
+
root: string;
|
|
139
|
+
}
|
|
140
|
+
/** Element check for the Bucket descriptor. */
|
|
141
|
+
export declare function isBucketElement(value: unknown): value is {
|
|
142
|
+
props: BucketProps;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Resolve a Bucket descriptor against the enclosing S3Provider (or its own
|
|
146
|
+
* full overrides) — children never need to know which half came from where.
|
|
147
|
+
*/
|
|
148
|
+
export declare function resolveBucket(element: {
|
|
149
|
+
props: BucketProps;
|
|
150
|
+
}, s3: S3Config | null): ResolvedBucket;
|
|
151
|
+
//# sourceMappingURL=s3-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-provider.d.ts","sourceRoot":"","sources":["../src/s3-provider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAA;IAChB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAA;IACd,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,iBAAiB,EAAE,MAAM,CAAA;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,EAAE,MAAM,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAEjD;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW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,IAAI,GAClB,cAAc,CA+BhB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* S3 capability — the platform's single source of object-storage truth.
|
|
4
|
+
*
|
|
5
|
+
* The provider publishes ONLY a store interface (which S3 is in play:
|
|
6
|
+
* MinIO, RustFS, AWS, …) plus the generic scoping descriptor. Consumers
|
|
7
|
+
* (Velero, CNPG, app packages) read it via useS3()/useContext and own
|
|
8
|
+
* their own conventions — prefix layout, credential keys, WAL archives.
|
|
9
|
+
* Nothing here knows which subsystems exist downstream.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.S3Context = void 0;
|
|
13
|
+
exports.MinIO = MinIO;
|
|
14
|
+
exports.AwsS3 = AwsS3;
|
|
15
|
+
exports.useS3 = useS3;
|
|
16
|
+
exports.S3Provider = S3Provider;
|
|
17
|
+
exports.Bucket = Bucket;
|
|
18
|
+
exports.isBucketElement = isBucketElement;
|
|
19
|
+
exports.resolveBucket = resolveBucket;
|
|
20
|
+
const core_1 = require("@r8s/core");
|
|
21
|
+
const defaults_1 = require("@r8s/core/defaults");
|
|
22
|
+
function MinIO(props) {
|
|
23
|
+
return { region: 'us-east-1', forcePathStyle: true, ...props };
|
|
24
|
+
}
|
|
25
|
+
function AwsS3(props) {
|
|
26
|
+
const { region, endpoint, ...rest } = props;
|
|
27
|
+
return {
|
|
28
|
+
endpoint: endpoint ?? `https://s3.${region}.amazonaws.com`,
|
|
29
|
+
region,
|
|
30
|
+
forcePathStyle: false,
|
|
31
|
+
...rest,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.S3Context = (0, defaults_1.createContext)(null);
|
|
35
|
+
/** Read the surrounding S3 configuration (null when no provider is set). */
|
|
36
|
+
function useS3() {
|
|
37
|
+
return (0, core_1.useContext)(exports.S3Context);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* S3Provider — publishes the platform's object store on context.
|
|
41
|
+
*
|
|
42
|
+
* Consumers resolve their own destinations from useS3(); <Bucket>
|
|
43
|
+
* scopes them; explicit per-consumer values always win.
|
|
44
|
+
*/
|
|
45
|
+
function S3Provider(props) {
|
|
46
|
+
const { provider, children } = props;
|
|
47
|
+
// Resolve the provider value: JSX elements of the convenience factories
|
|
48
|
+
// are invoked with their props; plain S3Config objects pass through.
|
|
49
|
+
let config;
|
|
50
|
+
if (provider &&
|
|
51
|
+
typeof provider === 'object' &&
|
|
52
|
+
'type' in provider &&
|
|
53
|
+
typeof provider.type === 'function') {
|
|
54
|
+
config = provider.type(provider.props);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
config = provider;
|
|
58
|
+
}
|
|
59
|
+
return (0, core_1.jsx)(exports.S3Context.Provider, { value: config, children });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Bucket — a declarative pointer at an S3 destination to pass into
|
|
63
|
+
* consumers' backup/bucket props:
|
|
64
|
+
*
|
|
65
|
+
* <Database name="api-db" backup={<Bucket name="matrix_backup" />} />
|
|
66
|
+
*
|
|
67
|
+
* Endpoint/credentials resolve from the surrounding S3Provider unless the
|
|
68
|
+
* descriptor overrides them, so the call site shows exactly where data
|
|
69
|
+
* goes without repeating store config. Consumers append their own
|
|
70
|
+
* conventional suffix (`-cnpg`, `velero`, …).
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* import { S3Provider, MinIO, Bucket, Database, Backup } from '@r8s/recipes'
|
|
74
|
+
*
|
|
75
|
+
* export default (
|
|
76
|
+
* <S3Provider provider={<MinIO endpoint="https://rustfs:9000" bucket="infra" credentialsSecret="infra-s3-creds" />}>
|
|
77
|
+
* <Database name="matrix-db" backup={<Bucket name="matrix_backup" />} />
|
|
78
|
+
* </S3Provider>
|
|
79
|
+
* )
|
|
80
|
+
*/
|
|
81
|
+
function Bucket(props) {
|
|
82
|
+
// Descriptors are VALUES — the renderer only reaches this body if someone
|
|
83
|
+
// renders <Bucket /> directly. Fail loudly instead of recursing.
|
|
84
|
+
throw new Error('Bucket is a descriptor, not a renderable component — pass it to consumers:' +
|
|
85
|
+
` <Database backup={<Bucket name="${props?.name ?? '…'}" />} />`);
|
|
86
|
+
}
|
|
87
|
+
/** Element check for the Bucket descriptor. */
|
|
88
|
+
function isBucketElement(value) {
|
|
89
|
+
return (!!value &&
|
|
90
|
+
typeof value === 'object' &&
|
|
91
|
+
'type' in value &&
|
|
92
|
+
value.type === Bucket);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Resolve a Bucket descriptor against the enclosing S3Provider (or its own
|
|
96
|
+
* full overrides) — children never need to know which half came from where.
|
|
97
|
+
*/
|
|
98
|
+
function resolveBucket(element, s3) {
|
|
99
|
+
const { name, bucket, endpoint, credentialsSecret } = element.props;
|
|
100
|
+
if (!name || name.includes('/') || name.includes('..')) {
|
|
101
|
+
throw new Error(`Bucket name "${name}" must be a single path segment without slashes or '..' — it becomes the prefix under s3://<bucket>/`);
|
|
102
|
+
}
|
|
103
|
+
const effective = {
|
|
104
|
+
...s3,
|
|
105
|
+
...(endpoint !== undefined && { endpoint }),
|
|
106
|
+
...(bucket !== undefined && { bucket }),
|
|
107
|
+
...(credentialsSecret !== undefined && { credentialsSecret }),
|
|
108
|
+
};
|
|
109
|
+
if (!effective.endpoint || !effective.bucket || !effective.credentialsSecret) {
|
|
110
|
+
throw new Error(`Bucket "${name}" cannot resolve its store config:\n` +
|
|
111
|
+
`\n` +
|
|
112
|
+
`Wrap the consumer in an <S3Provider> (endpoint/credentials derive from it)\n` +
|
|
113
|
+
`or give the descriptor the full config:\n` +
|
|
114
|
+
` <Bucket name="${name}" bucket="…" endpoint="https://…" credentialsSecret="…" />`);
|
|
115
|
+
}
|
|
116
|
+
// A bucket override isolates the destination — the provider's tenant
|
|
117
|
+
// prefix must not leak into another store.
|
|
118
|
+
const ownPrefix = bucket === undefined ? s3?.prefix : undefined;
|
|
119
|
+
const prefix = [ownPrefix, name].filter(Boolean).join('/');
|
|
120
|
+
return {
|
|
121
|
+
s3: effective,
|
|
122
|
+
prefix,
|
|
123
|
+
root: `s3://${effective.bucket}/${prefix}`,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=s3-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-provider.js","sourceRoot":"","sources":["../src/s3-provider.tsx"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAuDH,sBAEC;AAqBD,sBAQC;AAKD,sBAEC;AAuBD,gCAoBC;AAiCD,wBAOC;AAYD,0CAOC;AAMD,sCAkCC;AAzOD,oCAA2C;AAC3C,iDAAkD;AAoDlD,SAAgB,KAAK,CAAC,KAAiB;IACrC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,CAAA;AAChE,CAAC;AAqBD,SAAgB,KAAK,CAAC,KAAiB;IACrC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAA;IAC3C,OAAO;QACL,QAAQ,EAAE,QAAQ,IAAI,cAAc,MAAM,gBAAgB;QAC1D,MAAM;QACN,cAAc,EAAE,KAAK;QACrB,GAAG,IAAI;KACR,CAAA;AACH,CAAC;AAEY,QAAA,SAAS,GAAG,IAAA,wBAAa,EAAkB,IAAI,CAAC,CAAA;AAE7D,4EAA4E;AAC5E,SAAgB,KAAK;IACnB,OAAO,IAAA,iBAAU,EAAC,iBAAS,CAAC,CAAA;AAC9B,CAAC;AAiBD;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAsB;IAC/C,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAEpC,wEAAwE;IACxE,qEAAqE;IACrE,IAAI,MAAgB,CAAA;IACpB,IACE,QAAQ;QACR,OAAO,QAAQ,KAAK,QAAQ;QAC5B,MAAM,IAAI,QAA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