typekro 0.5.0 → 0.7.0
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/.tsbuildinfo +1 -1
- package/dist/core/composition/context.d.ts +14 -0
- package/dist/core/composition/context.d.ts.map +1 -1
- package/dist/core/composition/context.js.map +1 -1
- package/dist/core/composition/imperative.d.ts.map +1 -1
- package/dist/core/composition/imperative.js +59 -30
- package/dist/core/composition/imperative.js.map +1 -1
- package/dist/core/composition/nested-status-cel.d.ts +50 -0
- package/dist/core/composition/nested-status-cel.d.ts.map +1 -0
- package/dist/core/composition/nested-status-cel.js +169 -0
- package/dist/core/composition/nested-status-cel.js.map +1 -0
- package/dist/core/constants/brands.d.ts +1 -1
- package/dist/core/constants/brands.d.ts.map +1 -1
- package/dist/core/constants/brands.js +1 -1
- package/dist/core/constants/brands.js.map +1 -1
- package/dist/core/containers/build.d.ts +50 -0
- package/dist/core/containers/build.d.ts.map +1 -0
- package/dist/core/containers/build.js +146 -0
- package/dist/core/containers/build.js.map +1 -0
- package/dist/core/containers/errors.d.ts +14 -0
- package/dist/core/containers/errors.d.ts.map +1 -0
- package/dist/core/containers/errors.js +48 -0
- package/dist/core/containers/errors.js.map +1 -0
- package/dist/core/containers/exec.d.ts +36 -0
- package/dist/core/containers/exec.d.ts.map +1 -0
- package/dist/core/containers/exec.js +110 -0
- package/dist/core/containers/exec.js.map +1 -0
- package/dist/core/containers/index.d.ts +21 -0
- package/dist/core/containers/index.d.ts.map +1 -0
- package/dist/core/containers/index.js +20 -0
- package/dist/core/containers/index.js.map +1 -0
- package/dist/core/containers/registries/ecr.d.ts +22 -0
- package/dist/core/containers/registries/ecr.d.ts.map +1 -0
- package/dist/core/containers/registries/ecr.js +118 -0
- package/dist/core/containers/registries/ecr.js.map +1 -0
- package/dist/core/containers/registries/index.d.ts +9 -0
- package/dist/core/containers/registries/index.d.ts.map +1 -0
- package/dist/core/containers/registries/index.js +23 -0
- package/dist/core/containers/registries/index.js.map +1 -0
- package/dist/core/containers/registries/orbstack.d.ts +14 -0
- package/dist/core/containers/registries/orbstack.d.ts.map +1 -0
- package/dist/core/containers/registries/orbstack.js +24 -0
- package/dist/core/containers/registries/orbstack.js.map +1 -0
- package/dist/core/containers/registries/types.d.ts +94 -0
- package/dist/core/containers/registries/types.d.ts.map +1 -0
- package/dist/core/containers/registries/types.js +11 -0
- package/dist/core/containers/registries/types.js.map +1 -0
- package/dist/core/dependencies/graph.d.ts +4 -0
- package/dist/core/dependencies/graph.d.ts.map +1 -1
- package/dist/core/dependencies/graph.js +6 -0
- package/dist/core/dependencies/graph.js.map +1 -1
- package/dist/core/dependencies/resolver.d.ts +28 -0
- package/dist/core/dependencies/resolver.d.ts.map +1 -1
- package/dist/core/dependencies/resolver.js +138 -5
- package/dist/core/dependencies/resolver.js.map +1 -1
- package/dist/core/deployment/direct-factory.d.ts +13 -0
- package/dist/core/deployment/direct-factory.d.ts.map +1 -1
- package/dist/core/deployment/direct-factory.js +99 -0
- package/dist/core/deployment/direct-factory.js.map +1 -1
- package/dist/core/deployment/engine.d.ts.map +1 -1
- package/dist/core/deployment/engine.js +45 -2
- package/dist/core/deployment/engine.js.map +1 -1
- package/dist/core/deployment/kro-factory.d.ts +7 -0
- package/dist/core/deployment/kro-factory.d.ts.map +1 -1
- package/dist/core/deployment/kro-factory.js +203 -9
- package/dist/core/deployment/kro-factory.js.map +1 -1
- package/dist/core/deployment/kro-readiness.d.ts.map +1 -1
- package/dist/core/deployment/kro-readiness.js +10 -1
- package/dist/core/deployment/kro-readiness.js.map +1 -1
- package/dist/core/deployment/nested-composition-status.d.ts +33 -0
- package/dist/core/deployment/nested-composition-status.d.ts.map +1 -0
- package/dist/core/deployment/nested-composition-status.js +101 -0
- package/dist/core/deployment/nested-composition-status.js.map +1 -0
- package/dist/core/deployment/readiness-waiter.d.ts.map +1 -1
- package/dist/core/deployment/readiness-waiter.js +23 -6
- package/dist/core/deployment/readiness-waiter.js.map +1 -1
- package/dist/core/deployment/rollback-manager.d.ts.map +1 -1
- package/dist/core/deployment/rollback-manager.js +19 -0
- package/dist/core/deployment/rollback-manager.js.map +1 -1
- package/dist/core/deployment/strategies/direct-strategy.d.ts +6 -0
- package/dist/core/deployment/strategies/direct-strategy.d.ts.map +1 -1
- package/dist/core/deployment/strategies/direct-strategy.js +133 -35
- package/dist/core/deployment/strategies/direct-strategy.js.map +1 -1
- package/dist/core/expressions/composition/imperative-analyzer.d.ts +8 -0
- package/dist/core/expressions/composition/imperative-analyzer.d.ts.map +1 -1
- package/dist/core/expressions/composition/imperative-analyzer.js +111 -16
- package/dist/core/expressions/composition/imperative-analyzer.js.map +1 -1
- package/dist/core/metadata/resource-metadata.d.ts +4 -0
- package/dist/core/metadata/resource-metadata.d.ts.map +1 -1
- package/dist/core/metadata/resource-metadata.js.map +1 -1
- package/dist/core/proxy/create-resource.d.ts.map +1 -1
- package/dist/core/proxy/create-resource.js +63 -21
- package/dist/core/proxy/create-resource.js.map +1 -1
- package/dist/core/references/external-refs.d.ts +2 -0
- package/dist/core/references/external-refs.d.ts.map +1 -1
- package/dist/core/references/external-refs.js +3 -0
- package/dist/core/references/external-refs.js.map +1 -1
- package/dist/core/references/resolver.d.ts +12 -4
- package/dist/core/references/resolver.d.ts.map +1 -1
- package/dist/core/references/resolver.js +152 -69
- package/dist/core/references/resolver.js.map +1 -1
- package/dist/core/references/schema-proxy.d.ts.map +1 -1
- package/dist/core/references/schema-proxy.js +5 -4
- package/dist/core/references/schema-proxy.js.map +1 -1
- package/dist/core/serialization/cel-references.d.ts +1 -1
- package/dist/core/serialization/cel-references.d.ts.map +1 -1
- package/dist/core/serialization/cel-references.js +133 -8
- package/dist/core/serialization/cel-references.js.map +1 -1
- package/dist/core/serialization/core.d.ts +2 -0
- package/dist/core/serialization/core.d.ts.map +1 -1
- package/dist/core/serialization/core.js +16 -2
- package/dist/core/serialization/core.js.map +1 -1
- package/dist/core/serialization/schema.d.ts +2 -2
- package/dist/core/serialization/schema.d.ts.map +1 -1
- package/dist/core/serialization/schema.js +34 -17
- package/dist/core/serialization/schema.js.map +1 -1
- package/dist/core/serialization/status-analysis-pipeline.d.ts +4 -0
- package/dist/core/serialization/status-analysis-pipeline.d.ts.map +1 -1
- package/dist/core/serialization/status-analysis-pipeline.js +127 -10
- package/dist/core/serialization/status-analysis-pipeline.js.map +1 -1
- package/dist/core/serialization/yaml.d.ts.map +1 -1
- package/dist/core/serialization/yaml.js +7 -2
- package/dist/core/serialization/yaml.js.map +1 -1
- package/dist/core/types/composable.d.ts +62 -0
- package/dist/core/types/composable.d.ts.map +1 -0
- package/dist/core/types/composable.js +51 -0
- package/dist/core/types/composable.js.map +1 -0
- package/dist/core/types/deployment.d.ts +2 -1
- package/dist/core/types/deployment.d.ts.map +1 -1
- package/dist/core/types/index.d.ts +1 -0
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/core/types/index.js +1 -0
- package/dist/core/types/index.js.map +1 -1
- package/dist/core/types/serialization.d.ts +2 -1
- package/dist/core/types/serialization.d.ts.map +1 -1
- package/dist/core/validation/cel-validator.d.ts.map +1 -1
- package/dist/core/validation/cel-validator.js +55 -31
- package/dist/core/validation/cel-validator.js.map +1 -1
- package/dist/factories/cnpg/compositions/cnpg-bootstrap.d.ts +55 -0
- package/dist/factories/cnpg/compositions/cnpg-bootstrap.d.ts.map +1 -0
- package/dist/factories/cnpg/compositions/cnpg-bootstrap.js +92 -0
- package/dist/factories/cnpg/compositions/cnpg-bootstrap.js.map +1 -0
- package/dist/factories/cnpg/compositions/index.d.ts +2 -0
- package/dist/factories/cnpg/compositions/index.d.ts.map +1 -0
- package/dist/factories/cnpg/compositions/index.js +2 -0
- package/dist/factories/cnpg/compositions/index.js.map +1 -0
- package/dist/factories/cnpg/index.d.ts +42 -0
- package/dist/factories/cnpg/index.d.ts.map +1 -0
- package/dist/factories/cnpg/index.js +42 -0
- package/dist/factories/cnpg/index.js.map +1 -0
- package/dist/factories/cnpg/resources/backup.d.ts +34 -0
- package/dist/factories/cnpg/resources/backup.d.ts.map +1 -0
- package/dist/factories/cnpg/resources/backup.js +87 -0
- package/dist/factories/cnpg/resources/backup.js.map +1 -0
- package/dist/factories/cnpg/resources/cluster.d.ts +55 -0
- package/dist/factories/cnpg/resources/cluster.d.ts.map +1 -0
- package/dist/factories/cnpg/resources/cluster.js +123 -0
- package/dist/factories/cnpg/resources/cluster.js.map +1 -0
- package/dist/factories/cnpg/resources/helm.d.ts +45 -0
- package/dist/factories/cnpg/resources/helm.d.ts.map +1 -0
- package/dist/factories/cnpg/resources/helm.js +78 -0
- package/dist/factories/cnpg/resources/helm.js.map +1 -0
- package/dist/factories/cnpg/resources/index.d.ts +6 -0
- package/dist/factories/cnpg/resources/index.d.ts.map +1 -0
- package/dist/factories/cnpg/resources/index.js +6 -0
- package/dist/factories/cnpg/resources/index.js.map +1 -0
- package/dist/factories/cnpg/resources/pooler.d.ts +38 -0
- package/dist/factories/cnpg/resources/pooler.d.ts.map +1 -0
- package/dist/factories/cnpg/resources/pooler.js +97 -0
- package/dist/factories/cnpg/resources/pooler.js.map +1 -0
- package/dist/factories/cnpg/resources/scheduled-backup.d.ts +35 -0
- package/dist/factories/cnpg/resources/scheduled-backup.d.ts.map +1 -0
- package/dist/factories/cnpg/resources/scheduled-backup.js +68 -0
- package/dist/factories/cnpg/resources/scheduled-backup.js.map +1 -0
- package/dist/factories/cnpg/types.d.ts +507 -0
- package/dist/factories/cnpg/types.d.ts.map +1 -0
- package/dist/factories/cnpg/types.js +398 -0
- package/dist/factories/cnpg/types.js.map +1 -0
- package/dist/factories/cnpg/utils/helm-values-mapper.d.ts +70 -0
- package/dist/factories/cnpg/utils/helm-values-mapper.d.ts.map +1 -0
- package/dist/factories/cnpg/utils/helm-values-mapper.js +79 -0
- package/dist/factories/cnpg/utils/helm-values-mapper.js.map +1 -0
- package/dist/factories/cnpg/utils/index.d.ts +2 -0
- package/dist/factories/cnpg/utils/index.d.ts.map +1 -0
- package/dist/factories/cnpg/utils/index.js +2 -0
- package/dist/factories/cnpg/utils/index.js.map +1 -0
- package/dist/factories/helm/helm-release.d.ts.map +1 -1
- package/dist/factories/helm/helm-release.js +4 -0
- package/dist/factories/helm/helm-release.js.map +1 -1
- package/dist/factories/helm/types.d.ts +2 -0
- package/dist/factories/helm/types.d.ts.map +1 -1
- package/dist/factories/inngest/compositions/index.d.ts +2 -0
- package/dist/factories/inngest/compositions/index.d.ts.map +1 -0
- package/dist/factories/inngest/compositions/index.js +2 -0
- package/dist/factories/inngest/compositions/index.js.map +1 -0
- package/dist/factories/inngest/compositions/inngest-bootstrap.d.ts +150 -0
- package/dist/factories/inngest/compositions/inngest-bootstrap.d.ts.map +1 -0
- package/dist/factories/inngest/compositions/inngest-bootstrap.js +90 -0
- package/dist/factories/inngest/compositions/inngest-bootstrap.js.map +1 -0
- package/dist/factories/inngest/index.d.ts +45 -0
- package/dist/factories/inngest/index.d.ts.map +1 -0
- package/dist/factories/inngest/index.js +45 -0
- package/dist/factories/inngest/index.js.map +1 -0
- package/dist/factories/inngest/resources/helm.d.ts +53 -0
- package/dist/factories/inngest/resources/helm.d.ts.map +1 -0
- package/dist/factories/inngest/resources/helm.js +88 -0
- package/dist/factories/inngest/resources/helm.js.map +1 -0
- package/dist/factories/inngest/resources/index.d.ts +2 -0
- package/dist/factories/inngest/resources/index.d.ts.map +1 -0
- package/dist/factories/inngest/resources/index.js +2 -0
- package/dist/factories/inngest/resources/index.js.map +1 -0
- package/dist/factories/inngest/types.d.ts +177 -0
- package/dist/factories/inngest/types.d.ts.map +1 -0
- package/dist/factories/inngest/types.js +189 -0
- package/dist/factories/inngest/types.js.map +1 -0
- package/dist/factories/inngest/utils/helm-values-mapper.d.ts +127 -0
- package/dist/factories/inngest/utils/helm-values-mapper.d.ts.map +1 -0
- package/dist/factories/inngest/utils/helm-values-mapper.js +116 -0
- package/dist/factories/inngest/utils/helm-values-mapper.js.map +1 -0
- package/dist/factories/inngest/utils/index.d.ts +2 -0
- package/dist/factories/inngest/utils/index.d.ts.map +1 -0
- package/dist/factories/inngest/utils/index.js +2 -0
- package/dist/factories/inngest/utils/index.js.map +1 -0
- package/dist/factories/kubernetes/core/namespace.d.ts.map +1 -1
- package/dist/factories/kubernetes/core/namespace.js +1 -1
- package/dist/factories/kubernetes/core/namespace.js.map +1 -1
- package/dist/factories/valkey/compositions/index.d.ts +2 -0
- package/dist/factories/valkey/compositions/index.d.ts.map +1 -0
- package/dist/factories/valkey/compositions/index.js +2 -0
- package/dist/factories/valkey/compositions/index.js.map +1 -0
- package/dist/factories/valkey/compositions/valkey-bootstrap.d.ts +41 -0
- package/dist/factories/valkey/compositions/valkey-bootstrap.d.ts.map +1 -0
- package/dist/factories/valkey/compositions/valkey-bootstrap.js +105 -0
- package/dist/factories/valkey/compositions/valkey-bootstrap.js.map +1 -0
- package/dist/factories/valkey/index.d.ts +50 -0
- package/dist/factories/valkey/index.d.ts.map +1 -0
- package/dist/factories/valkey/index.js +50 -0
- package/dist/factories/valkey/index.js.map +1 -0
- package/dist/factories/valkey/resources/helm.d.ts +53 -0
- package/dist/factories/valkey/resources/helm.d.ts.map +1 -0
- package/dist/factories/valkey/resources/helm.js +82 -0
- package/dist/factories/valkey/resources/helm.js.map +1 -0
- package/dist/factories/valkey/resources/index.d.ts +3 -0
- package/dist/factories/valkey/resources/index.d.ts.map +1 -0
- package/dist/factories/valkey/resources/index.js +3 -0
- package/dist/factories/valkey/resources/index.js.map +1 -0
- package/dist/factories/valkey/resources/valkey.d.ts +46 -0
- package/dist/factories/valkey/resources/valkey.d.ts.map +1 -0
- package/dist/factories/valkey/resources/valkey.js +123 -0
- package/dist/factories/valkey/resources/valkey.js.map +1 -0
- package/dist/factories/valkey/types.d.ts +185 -0
- package/dist/factories/valkey/types.d.ts.map +1 -0
- package/dist/factories/valkey/types.js +204 -0
- package/dist/factories/valkey/types.js.map +1 -0
- package/dist/factories/valkey/utils/helm-values-mapper.d.ts +32 -0
- package/dist/factories/valkey/utils/helm-values-mapper.d.ts.map +1 -0
- package/dist/factories/valkey/utils/helm-values-mapper.js +58 -0
- package/dist/factories/valkey/utils/helm-values-mapper.js.map +1 -0
- package/dist/factories/valkey/utils/index.d.ts +2 -0
- package/dist/factories/valkey/utils/index.d.ts.map +1 -0
- package/dist/factories/valkey/utils/index.js +2 -0
- package/dist/factories/valkey/utils/index.js.map +1 -0
- package/dist/factories/webapp/compositions/index.d.ts +2 -0
- package/dist/factories/webapp/compositions/index.d.ts.map +1 -0
- package/dist/factories/webapp/compositions/index.js +2 -0
- package/dist/factories/webapp/compositions/index.js.map +1 -0
- package/dist/factories/webapp/compositions/web-app-with-processing.d.ts +98 -0
- package/dist/factories/webapp/compositions/web-app-with-processing.d.ts.map +1 -0
- package/dist/factories/webapp/compositions/web-app-with-processing.js +221 -0
- package/dist/factories/webapp/compositions/web-app-with-processing.js.map +1 -0
- package/dist/factories/webapp/index.d.ts +53 -0
- package/dist/factories/webapp/index.d.ts.map +1 -0
- package/dist/factories/webapp/index.js +53 -0
- package/dist/factories/webapp/index.js.map +1 -0
- package/dist/factories/webapp/types.d.ts +69 -0
- package/dist/factories/webapp/types.d.ts.map +1 -0
- package/dist/factories/webapp/types.js +92 -0
- package/dist/factories/webapp/types.js.map +1 -0
- package/dist/shared/brands.d.ts +16 -0
- package/dist/shared/brands.d.ts.map +1 -1
- package/dist/shared/brands.js +16 -0
- package/dist/shared/brands.js.map +1 -1
- package/package.json +25 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG Cluster Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates a CNPG Cluster resource representing a PostgreSQL cluster
|
|
5
|
+
* managed by the CloudNativePG operator.
|
|
6
|
+
*/
|
|
7
|
+
import { createConditionBasedReadinessEvaluator } from '../../../core/readiness/index.js';
|
|
8
|
+
import { createResource } from '../../shared.js';
|
|
9
|
+
/**
|
|
10
|
+
* Known CNPG cluster phase strings.
|
|
11
|
+
*
|
|
12
|
+
* These are human-readable strings from the CNPG operator status.phase field.
|
|
13
|
+
* Extracted as constants for maintainability — if CNPG changes these strings
|
|
14
|
+
* in a future operator release, updates are centralized here.
|
|
15
|
+
*/
|
|
16
|
+
export const CNPG_CLUSTER_PHASES = {
|
|
17
|
+
HEALTHY: 'Cluster in healthy state',
|
|
18
|
+
SETTING_UP_PRIMARY: 'Setting up primary',
|
|
19
|
+
CREATING_REPLICA: 'Creating replica',
|
|
20
|
+
FAILING_OVER: 'Failing over',
|
|
21
|
+
SWITCHOVER: 'Switchover in progress',
|
|
22
|
+
};
|
|
23
|
+
/** Base condition-based evaluator for Cluster Ready condition. */
|
|
24
|
+
const baseClusterEvaluator = createConditionBasedReadinessEvaluator({ kind: 'Cluster' });
|
|
25
|
+
/**
|
|
26
|
+
* Cluster Readiness Evaluator
|
|
27
|
+
*
|
|
28
|
+
* Checks both the standard Ready condition and the CNPG-specific `phase` field.
|
|
29
|
+
* CNPG clusters report phase as a human-readable string rather than a standard
|
|
30
|
+
* Kubernetes condition in some cases.
|
|
31
|
+
*/
|
|
32
|
+
function clusterReadinessEvaluator(liveResource) {
|
|
33
|
+
const resource = liveResource;
|
|
34
|
+
const status = resource?.status;
|
|
35
|
+
if (!status) {
|
|
36
|
+
return {
|
|
37
|
+
ready: false,
|
|
38
|
+
message: 'Cluster has no status yet',
|
|
39
|
+
reason: 'StatusMissing',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const phase = status.phase;
|
|
43
|
+
if (phase === CNPG_CLUSTER_PHASES.HEALTHY) {
|
|
44
|
+
return {
|
|
45
|
+
ready: true,
|
|
46
|
+
message: `Cluster is healthy (${status.readyInstances ?? 0}/${status.instances ?? 0} instances ready)`,
|
|
47
|
+
reason: 'Healthy',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (phase === CNPG_CLUSTER_PHASES.SETTING_UP_PRIMARY) {
|
|
51
|
+
return {
|
|
52
|
+
ready: false,
|
|
53
|
+
message: 'Cluster is setting up the primary instance',
|
|
54
|
+
reason: 'SettingUpPrimary',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (phase === CNPG_CLUSTER_PHASES.CREATING_REPLICA) {
|
|
58
|
+
return {
|
|
59
|
+
ready: false,
|
|
60
|
+
message: `Creating replicas (${status.readyInstances ?? 0}/${status.instances ?? 0} ready)`,
|
|
61
|
+
reason: 'CreatingReplica',
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (phase === CNPG_CLUSTER_PHASES.FAILING_OVER || phase === CNPG_CLUSTER_PHASES.SWITCHOVER) {
|
|
65
|
+
return {
|
|
66
|
+
ready: false,
|
|
67
|
+
message: `Cluster is performing failover: ${phase}`,
|
|
68
|
+
reason: 'Failover',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Fall back to condition-based evaluation for unknown phases
|
|
72
|
+
return baseClusterEvaluator(liveResource);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* CloudNativePG Cluster Factory
|
|
76
|
+
*
|
|
77
|
+
* Creates a PostgreSQL cluster managed by the CNPG operator. Supports
|
|
78
|
+
* single-instance and multi-replica configurations with full backup,
|
|
79
|
+
* monitoring, and high-availability features.
|
|
80
|
+
*
|
|
81
|
+
* @param config - Cluster configuration following postgresql.cnpg.io/v1 API
|
|
82
|
+
* @returns Enhanced Cluster resource with readiness evaluation
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const db = cluster({
|
|
87
|
+
* name: 'my-database',
|
|
88
|
+
* namespace: 'databases',
|
|
89
|
+
* spec: {
|
|
90
|
+
* instances: 3,
|
|
91
|
+
* storage: { size: '50Gi', storageClass: 'gp3' },
|
|
92
|
+
* postgresql: {
|
|
93
|
+
* parameters: { shared_buffers: '256MB' },
|
|
94
|
+
* },
|
|
95
|
+
* bootstrap: {
|
|
96
|
+
* initdb: { database: 'myapp', owner: 'myapp' },
|
|
97
|
+
* },
|
|
98
|
+
* },
|
|
99
|
+
* id: 'primaryDatabase',
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
function createClusterResource(config) {
|
|
104
|
+
const fullConfig = {
|
|
105
|
+
...config,
|
|
106
|
+
spec: {
|
|
107
|
+
...config.spec,
|
|
108
|
+
instances: config.spec.instances ?? 1,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
return createResource({
|
|
112
|
+
apiVersion: 'postgresql.cnpg.io/v1',
|
|
113
|
+
kind: 'Cluster',
|
|
114
|
+
metadata: {
|
|
115
|
+
name: fullConfig.name,
|
|
116
|
+
...(fullConfig.namespace && { namespace: fullConfig.namespace }),
|
|
117
|
+
},
|
|
118
|
+
spec: fullConfig.spec,
|
|
119
|
+
...(fullConfig.id && { id: fullConfig.id }),
|
|
120
|
+
}, { scope: 'namespaced' }).withReadinessEvaluator(clusterReadinessEvaluator);
|
|
121
|
+
}
|
|
122
|
+
export const cluster = createClusterResource;
|
|
123
|
+
//# sourceMappingURL=cluster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster.js","sourceRoot":"","sources":["../../../../src/factories/cnpg/resources/cluster.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG Helm Resource Factories
|
|
3
|
+
*
|
|
4
|
+
* Wrappers around the generic Helm factories with CNPG-specific defaults.
|
|
5
|
+
* Used by the cnpgBootstrap composition to install the operator.
|
|
6
|
+
*/
|
|
7
|
+
import type { Composable, Enhanced } from '../../../core/types/index.js';
|
|
8
|
+
import { type HelmRepositorySpec, type HelmRepositoryStatus } from '../../helm/helm-repository.js';
|
|
9
|
+
import type { HelmReleaseSpec, HelmReleaseStatus } from '../../helm/types.js';
|
|
10
|
+
import type { CnpgHelmReleaseConfig, CnpgHelmRepositoryConfig } from '../types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Create a HelmRepository for the CloudNativePG chart repository.
|
|
13
|
+
*
|
|
14
|
+
* @param config - Repository configuration with CNPG-specific defaults
|
|
15
|
+
* @returns Enhanced HelmRepository resource
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const repo = cnpgHelmRepository({
|
|
20
|
+
* name: 'cnpg-repo',
|
|
21
|
+
* namespace: 'flux-system',
|
|
22
|
+
* id: 'cnpgHelmRepository',
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function cnpgHelmRepository(config: Composable<CnpgHelmRepositoryConfig>): Enhanced<HelmRepositorySpec, HelmRepositoryStatus>;
|
|
27
|
+
/**
|
|
28
|
+
* Create a HelmRelease for the CloudNativePG operator.
|
|
29
|
+
*
|
|
30
|
+
* @param config - Release configuration with CNPG-specific defaults
|
|
31
|
+
* @returns Enhanced HelmRelease resource
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const release = cnpgHelmRelease({
|
|
36
|
+
* name: 'cnpg',
|
|
37
|
+
* namespace: 'cnpg-system',
|
|
38
|
+
* version: '0.23.0',
|
|
39
|
+
* values: { crds: { create: true } },
|
|
40
|
+
* id: 'cnpgHelmRelease',
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function cnpgHelmRelease(config: Composable<CnpgHelmReleaseConfig>): Enhanced<HelmReleaseSpec, HelmReleaseStatus>;
|
|
45
|
+
//# sourceMappingURL=helm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helm.d.ts","sourceRoot":"","sources":["../../../../src/factories/cnpg/resources/helm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAQnF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,GAC3C,QAAQ,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAUpD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,UAAU,CAAC,qBAAqB,CAAC,GACxC,QAAQ,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAuB9C"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG Helm Resource Factories
|
|
3
|
+
*
|
|
4
|
+
* Wrappers around the generic Helm factories with CNPG-specific defaults.
|
|
5
|
+
* Used by the cnpgBootstrap composition to install the operator.
|
|
6
|
+
*/
|
|
7
|
+
import { DEFAULT_FLUX_NAMESPACE } from '../../../core/config/defaults.js';
|
|
8
|
+
import { createHelmRepositoryReadinessEvaluator, helmRepository, } from '../../helm/helm-repository.js';
|
|
9
|
+
import { createLabeledHelmReleaseEvaluator } from '../../helm/readiness-evaluators.js';
|
|
10
|
+
import { helmRelease } from '../../helm/helm-release.js';
|
|
11
|
+
/** Default Helm chart repository URL for CloudNativePG. */
|
|
12
|
+
const DEFAULT_CNPG_REPO_URL = 'https://cloudnative-pg.github.io/charts';
|
|
13
|
+
/** Default chart version. */
|
|
14
|
+
const DEFAULT_CNPG_VERSION = '0.23.0';
|
|
15
|
+
/**
|
|
16
|
+
* Create a HelmRepository for the CloudNativePG chart repository.
|
|
17
|
+
*
|
|
18
|
+
* @param config - Repository configuration with CNPG-specific defaults
|
|
19
|
+
* @returns Enhanced HelmRepository resource
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const repo = cnpgHelmRepository({
|
|
24
|
+
* name: 'cnpg-repo',
|
|
25
|
+
* namespace: 'flux-system',
|
|
26
|
+
* id: 'cnpgHelmRepository',
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function cnpgHelmRepository(config) {
|
|
31
|
+
return helmRepository({
|
|
32
|
+
name: config.name || 'cnpg-repo',
|
|
33
|
+
namespace: config.namespace || DEFAULT_FLUX_NAMESPACE,
|
|
34
|
+
url: config.url || DEFAULT_CNPG_REPO_URL,
|
|
35
|
+
interval: config.interval || '5m',
|
|
36
|
+
...(config.id && { id: config.id }),
|
|
37
|
+
}).withReadinessEvaluator(createHelmRepositoryReadinessEvaluator('CNPG'));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create a HelmRelease for the CloudNativePG operator.
|
|
41
|
+
*
|
|
42
|
+
* @param config - Release configuration with CNPG-specific defaults
|
|
43
|
+
* @returns Enhanced HelmRelease resource
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const release = cnpgHelmRelease({
|
|
48
|
+
* name: 'cnpg',
|
|
49
|
+
* namespace: 'cnpg-system',
|
|
50
|
+
* version: '0.23.0',
|
|
51
|
+
* values: { crds: { create: true } },
|
|
52
|
+
* id: 'cnpgHelmRelease',
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export function cnpgHelmRelease(config) {
|
|
57
|
+
// Pass values directly — the core proxy system handles serialization.
|
|
58
|
+
return helmRelease({
|
|
59
|
+
name: config.name,
|
|
60
|
+
namespace: config.namespace || 'cnpg-system',
|
|
61
|
+
chart: {
|
|
62
|
+
repository: DEFAULT_CNPG_REPO_URL,
|
|
63
|
+
name: 'cloudnative-pg',
|
|
64
|
+
version: config.version || DEFAULT_CNPG_VERSION,
|
|
65
|
+
},
|
|
66
|
+
sourceRef: {
|
|
67
|
+
name: config.repositoryName || 'cnpg-repo',
|
|
68
|
+
namespace: DEFAULT_FLUX_NAMESPACE,
|
|
69
|
+
kind: 'HelmRepository',
|
|
70
|
+
},
|
|
71
|
+
values: {
|
|
72
|
+
crds: { create: true },
|
|
73
|
+
...(config.values || {}),
|
|
74
|
+
},
|
|
75
|
+
...(config.id && { id: config.id }),
|
|
76
|
+
}).withReadinessEvaluator(createLabeledHelmReleaseEvaluator('CNPG'));
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=helm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helm.js","sourceRoot":"","sources":["../../../../src/factories/cnpg/resources/helm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,OAAO,EACL,sCAAsC,EACtC,cAAc,GAGf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AAEvF,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAGzD,2DAA2D;AAC3D,MAAM,qBAAqB,GAAG,yCAAyC,CAAC;AAExE,6BAA6B;AAC7B,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AAEtC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA4C;IAE5C,OAAO,cAAc,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,WAAW;QAChC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,sBAAsB;QACrD,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,qBAAqB;QACxC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;QACjC,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;KACpC,CAAC,CAAC,sBAAsB,CACvB,sCAAsC,CAAC,MAAM,CAAC,CACO,CAAC;AAC1D,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAyC;IAEzC,sEAAsE;IACtE,OAAO,WAAW,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,aAAa;QAC5C,KAAK,EAAE;YACL,UAAU,EAAE,qBAAqB;YACjC,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,oBAAoB;SAChD;QACD,SAAS,EAAE;YACT,IAAI,EAAE,MAAM,CAAC,cAAc,IAAI,WAAW;YAC1C,SAAS,EAAE,sBAAsB;YACjC,IAAI,EAAE,gBAAgB;SACvB;QACD,MAAM,EAAE;YACN,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;YACtB,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;SACzB;QACD,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;KACpC,CAAC,CAAC,sBAAsB,CACvB,iCAAiC,CAAC,MAAM,CAAC,CACM,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/factories/cnpg/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/factories/cnpg/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG Pooler Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates a CNPG Pooler resource for PgBouncer connection pooling.
|
|
5
|
+
*/
|
|
6
|
+
import type { Composable, Enhanced } from '../../../core/types/index.js';
|
|
7
|
+
import type { PoolerConfig, PoolerStatus } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* CloudNativePG Pooler Factory
|
|
10
|
+
*
|
|
11
|
+
* Creates a PgBouncer connection pooler for a PostgreSQL cluster.
|
|
12
|
+
* Supports session and transaction pooling modes.
|
|
13
|
+
*
|
|
14
|
+
* @param config - Pooler configuration following postgresql.cnpg.io/v1 API
|
|
15
|
+
* @returns Enhanced Pooler resource with readiness evaluation
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const pool = pooler({
|
|
20
|
+
* name: 'my-db-pooler',
|
|
21
|
+
* namespace: 'databases',
|
|
22
|
+
* spec: {
|
|
23
|
+
* cluster: { name: 'my-database' },
|
|
24
|
+
* type: 'rw',
|
|
25
|
+
* instances: 2,
|
|
26
|
+
* pgbouncer: {
|
|
27
|
+
* poolMode: 'transaction',
|
|
28
|
+
* parameters: { default_pool_size: '25' },
|
|
29
|
+
* },
|
|
30
|
+
* },
|
|
31
|
+
* id: 'dbPooler',
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function createPoolerResource(config: Composable<PoolerConfig>): Enhanced<PoolerConfig['spec'], PoolerStatus>;
|
|
36
|
+
export declare const pooler: typeof createPoolerResource;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=pooler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pooler.d.ts","sourceRoot":"","sources":["../../../../src/factories/cnpg/resources/pooler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAkB,MAAM,8BAA8B,CAAC;AAEzF,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgD9D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,iBAAS,oBAAoB,CAC3B,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,GAC/B,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CA6B9C;AAED,eAAO,MAAM,MAAM,6BAAuB,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG Pooler Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates a CNPG Pooler resource for PgBouncer connection pooling.
|
|
5
|
+
*/
|
|
6
|
+
import { createResource } from '../../shared.js';
|
|
7
|
+
/**
|
|
8
|
+
* Pooler Readiness Evaluator
|
|
9
|
+
*
|
|
10
|
+
* CNPG Pooler status varies by version. Some report `status.instances` and
|
|
11
|
+
* `status.conditions`, others only report `status.secrets` once configured.
|
|
12
|
+
* We check multiple signals:
|
|
13
|
+
* 1. `status.ready === true` (if available)
|
|
14
|
+
* 2. `status.instances >= 1` (if available)
|
|
15
|
+
* 3. `status.secrets` populated (PgBouncer configured and connected to cluster)
|
|
16
|
+
* 4. Condition-based fallback
|
|
17
|
+
*/
|
|
18
|
+
function poolerReadinessEvaluator(liveResource) {
|
|
19
|
+
const resource = liveResource;
|
|
20
|
+
const status = resource?.status;
|
|
21
|
+
if (!status) {
|
|
22
|
+
return { ready: false, message: 'Pooler has no status yet', reason: 'StatusMissing' };
|
|
23
|
+
}
|
|
24
|
+
// Explicit ready field
|
|
25
|
+
if (status.ready === true) {
|
|
26
|
+
return { ready: true, message: 'Pooler is ready', reason: 'Ready' };
|
|
27
|
+
}
|
|
28
|
+
// Instance count check
|
|
29
|
+
if (typeof status.instances === 'number' && status.instances >= 1) {
|
|
30
|
+
return { ready: true, message: `Pooler has ${status.instances} instance(s)`, reason: 'Ready' };
|
|
31
|
+
}
|
|
32
|
+
// Secrets populated = PgBouncer is configured and connected
|
|
33
|
+
if (status.secrets && typeof status.secrets === 'object' && Object.keys(status.secrets).length > 0) {
|
|
34
|
+
return { ready: true, message: 'Pooler secrets configured', reason: 'Ready' };
|
|
35
|
+
}
|
|
36
|
+
// Condition-based fallback
|
|
37
|
+
const readyCondition = status.conditions?.find((c) => c.type === 'Ready');
|
|
38
|
+
if (readyCondition?.status === 'True') {
|
|
39
|
+
return { ready: true, message: readyCondition.message || 'Pooler is ready', reason: 'Ready' };
|
|
40
|
+
}
|
|
41
|
+
if (readyCondition) {
|
|
42
|
+
return { ready: false, message: readyCondition.message || 'Pooler is not ready', reason: readyCondition.reason || 'NotReady' };
|
|
43
|
+
}
|
|
44
|
+
return { ready: false, message: 'Pooler status incomplete', reason: 'Unknown' };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* CloudNativePG Pooler Factory
|
|
48
|
+
*
|
|
49
|
+
* Creates a PgBouncer connection pooler for a PostgreSQL cluster.
|
|
50
|
+
* Supports session and transaction pooling modes.
|
|
51
|
+
*
|
|
52
|
+
* @param config - Pooler configuration following postgresql.cnpg.io/v1 API
|
|
53
|
+
* @returns Enhanced Pooler resource with readiness evaluation
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const pool = pooler({
|
|
58
|
+
* name: 'my-db-pooler',
|
|
59
|
+
* namespace: 'databases',
|
|
60
|
+
* spec: {
|
|
61
|
+
* cluster: { name: 'my-database' },
|
|
62
|
+
* type: 'rw',
|
|
63
|
+
* instances: 2,
|
|
64
|
+
* pgbouncer: {
|
|
65
|
+
* poolMode: 'transaction',
|
|
66
|
+
* parameters: { default_pool_size: '25' },
|
|
67
|
+
* },
|
|
68
|
+
* },
|
|
69
|
+
* id: 'dbPooler',
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
function createPoolerResource(config) {
|
|
74
|
+
const fullConfig = {
|
|
75
|
+
...config,
|
|
76
|
+
spec: {
|
|
77
|
+
...config.spec,
|
|
78
|
+
instances: config.spec.instances ?? 1,
|
|
79
|
+
pgbouncer: {
|
|
80
|
+
poolMode: 'session',
|
|
81
|
+
...config.spec.pgbouncer,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
return createResource({
|
|
86
|
+
apiVersion: 'postgresql.cnpg.io/v1',
|
|
87
|
+
kind: 'Pooler',
|
|
88
|
+
metadata: {
|
|
89
|
+
name: fullConfig.name,
|
|
90
|
+
...(fullConfig.namespace && { namespace: fullConfig.namespace }),
|
|
91
|
+
},
|
|
92
|
+
spec: fullConfig.spec,
|
|
93
|
+
...(fullConfig.id && { id: fullConfig.id }),
|
|
94
|
+
}, { scope: 'namespaced' }).withReadinessEvaluator(poolerReadinessEvaluator);
|
|
95
|
+
}
|
|
96
|
+
export const pooler = createPoolerResource;
|
|
97
|
+
//# sourceMappingURL=pooler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pooler.js","sourceRoot":"","sources":["../../../../src/factories/cnpg/resources/pooler.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG ScheduledBackup Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates a CNPG ScheduledBackup resource for cron-based automated backups.
|
|
5
|
+
*/
|
|
6
|
+
import type { Composable, Enhanced } from '../../../core/types/index.js';
|
|
7
|
+
import type { ScheduledBackupConfig, ScheduledBackupStatus } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* CloudNativePG ScheduledBackup Factory
|
|
10
|
+
*
|
|
11
|
+
* Creates a cron-scheduled backup for a PostgreSQL cluster.
|
|
12
|
+
* Uses robfig/cron format with seconds: 'second minute hour day month day-of-week'.
|
|
13
|
+
*
|
|
14
|
+
* @param config - ScheduledBackup configuration following postgresql.cnpg.io/v1 API
|
|
15
|
+
* @returns Enhanced ScheduledBackup resource with readiness evaluation
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const nightlyBackup = scheduledBackup({
|
|
20
|
+
* name: 'nightly-backup',
|
|
21
|
+
* namespace: 'databases',
|
|
22
|
+
* spec: {
|
|
23
|
+
* cluster: { name: 'my-database' },
|
|
24
|
+
* schedule: '0 0 2 * * *',
|
|
25
|
+
* immediate: true,
|
|
26
|
+
* backupOwnerReference: 'cluster',
|
|
27
|
+
* },
|
|
28
|
+
* id: 'nightlyBackup',
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare function createScheduledBackupResource(config: Composable<ScheduledBackupConfig>): Enhanced<ScheduledBackupConfig['spec'], ScheduledBackupStatus>;
|
|
33
|
+
export declare const scheduledBackup: typeof createScheduledBackupResource;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=scheduled-backup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduled-backup.d.ts","sourceRoot":"","sources":["../../../../src/factories/cnpg/resources/scheduled-backup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAkB,MAAM,8BAA8B,CAAC;AAEzF,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA6BhF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAS,6BAA6B,CACpC,MAAM,EAAE,UAAU,CAAC,qBAAqB,CAAC,GACxC,QAAQ,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC,CAiBhE;AAED,eAAO,MAAM,eAAe,sCAAgC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG ScheduledBackup Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates a CNPG ScheduledBackup resource for cron-based automated backups.
|
|
5
|
+
*/
|
|
6
|
+
import { createConditionBasedReadinessEvaluator } from '../../../core/readiness/index.js';
|
|
7
|
+
import { createResource } from '../../shared.js';
|
|
8
|
+
/** Base condition-based evaluator. */
|
|
9
|
+
const baseEvaluator = createConditionBasedReadinessEvaluator({ kind: 'ScheduledBackup' });
|
|
10
|
+
/**
|
|
11
|
+
* ScheduledBackup Readiness Evaluator
|
|
12
|
+
*
|
|
13
|
+
* Checks standard Ready condition. If no conditions exist, checks whether
|
|
14
|
+
* the schedule has been evaluated (lastScheduleTime) as a proxy for readiness.
|
|
15
|
+
*/
|
|
16
|
+
function scheduledBackupReadinessEvaluator(liveResource) {
|
|
17
|
+
const result = baseEvaluator(liveResource);
|
|
18
|
+
// If conditions are missing but the schedule is running, consider it ready
|
|
19
|
+
if (!result.ready && result.reason === 'ConditionsMissing') {
|
|
20
|
+
const resource = liveResource;
|
|
21
|
+
if (resource?.status?.lastScheduleTime) {
|
|
22
|
+
return {
|
|
23
|
+
ready: true,
|
|
24
|
+
message: `Schedule is active, last run: ${resource.status.lastScheduleTime}`,
|
|
25
|
+
reason: 'ScheduleActive',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* CloudNativePG ScheduledBackup Factory
|
|
33
|
+
*
|
|
34
|
+
* Creates a cron-scheduled backup for a PostgreSQL cluster.
|
|
35
|
+
* Uses robfig/cron format with seconds: 'second minute hour day month day-of-week'.
|
|
36
|
+
*
|
|
37
|
+
* @param config - ScheduledBackup configuration following postgresql.cnpg.io/v1 API
|
|
38
|
+
* @returns Enhanced ScheduledBackup resource with readiness evaluation
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const nightlyBackup = scheduledBackup({
|
|
43
|
+
* name: 'nightly-backup',
|
|
44
|
+
* namespace: 'databases',
|
|
45
|
+
* spec: {
|
|
46
|
+
* cluster: { name: 'my-database' },
|
|
47
|
+
* schedule: '0 0 2 * * *',
|
|
48
|
+
* immediate: true,
|
|
49
|
+
* backupOwnerReference: 'cluster',
|
|
50
|
+
* },
|
|
51
|
+
* id: 'nightlyBackup',
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
function createScheduledBackupResource(config) {
|
|
56
|
+
return createResource({
|
|
57
|
+
apiVersion: 'postgresql.cnpg.io/v1',
|
|
58
|
+
kind: 'ScheduledBackup',
|
|
59
|
+
metadata: {
|
|
60
|
+
name: config.name,
|
|
61
|
+
...(config.namespace && { namespace: config.namespace }),
|
|
62
|
+
},
|
|
63
|
+
spec: config.spec,
|
|
64
|
+
...(config.id && { id: config.id }),
|
|
65
|
+
}, { scope: 'namespaced' }).withReadinessEvaluator(scheduledBackupReadinessEvaluator);
|
|
66
|
+
}
|
|
67
|
+
export const scheduledBackup = createScheduledBackupResource;
|
|
68
|
+
//# sourceMappingURL=scheduled-backup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduled-backup.js","sourceRoot":"","sources":["../../../../src/factories/cnpg/resources/scheduled-backup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,sCAAsC,EAAE,MAAM,kCAAkC,CAAC;AAE1F,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,sCAAsC;AACtC,MAAM,aAAa,GAAG,sCAAsC,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAE1F;;;;;GAKG;AACH,SAAS,iCAAiC,CAAC,YAAqB;IAC9D,MAAM,MAAM,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;IAE3C,2EAA2E;IAC3E,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,KAAK,mBAAmB,EAAE,CAAC;QAC3D,MAAM,QAAQ,GAAG,YAAqE,CAAC;QACvF,IAAI,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;YACvC,OAAO;gBACL,KAAK,EAAE,IAAI;gBACX,OAAO,EAAE,iCAAiC,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE;gBAC5E,MAAM,EAAE,gBAAgB;aACzB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAS,6BAA6B,CACpC,MAAyC;IAEzC,OAAO,cAAc,CACnB;QACE,UAAU,EAAE,uBAAuB;QACnC,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;SACzD;QACD,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;KACpC,EACD,EAAE,KAAK,EAAE,YAAY,EAAE,CACxB,CAAC,sBAAsB,CAAC,iCAAiC,CAGzD,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,6BAA6B,CAAC"}
|