typekro 0.5.0 → 0.8.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/compositions/typekro-runtime/typekro-runtime.d.ts +1 -1
- package/dist/compositions/typekro-runtime/typekro-runtime.d.ts.map +1 -1
- package/dist/compositions/typekro-runtime/typekro-runtime.js +16 -2
- package/dist/compositions/typekro-runtime/typekro-runtime.js.map +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 +28 -0
- package/dist/core/deployment/kro-factory.d.ts.map +1 -1
- package/dist/core/deployment/kro-factory.js +243 -13
- 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/composition-analyzer-helpers.d.ts +8 -2
- package/dist/core/expressions/composition/composition-analyzer-helpers.d.ts.map +1 -1
- package/dist/core/expressions/composition/composition-analyzer-helpers.js +34 -2
- package/dist/core/expressions/composition/composition-analyzer-helpers.js.map +1 -1
- package/dist/core/expressions/composition/composition-analyzer-ternary.d.ts.map +1 -1
- package/dist/core/expressions/composition/composition-analyzer-ternary.js +52 -28
- package/dist/core/expressions/composition/composition-analyzer-ternary.js.map +1 -1
- package/dist/core/expressions/composition/composition-analyzer-traversal.d.ts.map +1 -1
- package/dist/core/expressions/composition/composition-analyzer-traversal.js +11 -4
- package/dist/core/expressions/composition/composition-analyzer-traversal.js.map +1 -1
- package/dist/core/expressions/composition/composition-analyzer-types.d.ts +8 -0
- package/dist/core/expressions/composition/composition-analyzer-types.d.ts.map +1 -1
- package/dist/core/expressions/composition/composition-analyzer.d.ts +1 -1
- package/dist/core/expressions/composition/composition-analyzer.d.ts.map +1 -1
- package/dist/core/expressions/composition/composition-analyzer.js +8 -2
- package/dist/core/expressions/composition/composition-analyzer.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/cel.d.ts +48 -0
- package/dist/core/references/cel.d.ts.map +1 -1
- package/dist/core/references/cel.js +82 -0
- package/dist/core/references/cel.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 +191 -24
- package/dist/core/serialization/cel-references.js.map +1 -1
- package/dist/core/serialization/core.d.ts +8 -1
- package/dist/core/serialization/core.d.ts.map +1 -1
- package/dist/core/serialization/core.js +434 -7
- package/dist/core/serialization/core.js.map +1 -1
- package/dist/core/serialization/kro-post-processing.d.ts +46 -0
- package/dist/core/serialization/kro-post-processing.d.ts.map +1 -0
- package/dist/core/serialization/kro-post-processing.js +103 -0
- package/dist/core/serialization/kro-post-processing.js.map +1 -0
- package/dist/core/serialization/schema.d.ts +61 -3
- package/dist/core/serialization/schema.d.ts.map +1 -1
- package/dist/core/serialization/schema.js +520 -18
- 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 +27 -4
- 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 +40 -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/config/secret.d.ts.map +1 -1
- package/dist/factories/kubernetes/config/secret.js +11 -1
- package/dist/factories/kubernetes/config/secret.js.map +1 -1
- 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/searxng/compositions/index.d.ts +2 -0
- package/dist/factories/searxng/compositions/index.d.ts.map +1 -0
- package/dist/factories/searxng/compositions/index.js +2 -0
- package/dist/factories/searxng/compositions/index.js.map +1 -0
- package/dist/factories/searxng/compositions/searxng-bootstrap.d.ts +65 -0
- package/dist/factories/searxng/compositions/searxng-bootstrap.d.ts.map +1 -0
- package/dist/factories/searxng/compositions/searxng-bootstrap.js +237 -0
- package/dist/factories/searxng/compositions/searxng-bootstrap.js.map +1 -0
- package/dist/factories/searxng/index.d.ts +29 -0
- package/dist/factories/searxng/index.d.ts.map +1 -0
- package/dist/factories/searxng/index.js +27 -0
- package/dist/factories/searxng/index.js.map +1 -0
- package/dist/factories/searxng/resources/index.d.ts +2 -0
- package/dist/factories/searxng/resources/index.d.ts.map +1 -0
- package/dist/factories/searxng/resources/index.js +2 -0
- package/dist/factories/searxng/resources/index.js.map +1 -0
- package/dist/factories/searxng/resources/searxng.d.ts +65 -0
- package/dist/factories/searxng/resources/searxng.d.ts.map +1 -0
- package/dist/factories/searxng/resources/searxng.js +188 -0
- package/dist/factories/searxng/resources/searxng.js.map +1 -0
- package/dist/factories/searxng/types.d.ts +126 -0
- package/dist/factories/searxng/types.d.ts.map +1 -0
- package/dist/factories/searxng/types.js +176 -0
- package/dist/factories/searxng/types.js.map +1 -0
- package/dist/factories/searxng/utils/settings-builder.d.ts +46 -0
- package/dist/factories/searxng/utils/settings-builder.d.ts.map +1 -0
- package/dist/factories/searxng/utils/settings-builder.js +52 -0
- package/dist/factories/searxng/utils/settings-builder.js.map +1 -0
- package/dist/factories/simple/config/secret.d.ts.map +1 -1
- package/dist/factories/simple/config/secret.js +28 -0
- package/dist/factories/simple/config/secret.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 +97 -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 +220 -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 +29 -1
|
@@ -25,10 +25,40 @@ export interface KroSimpleSchema {
|
|
|
25
25
|
kind: string;
|
|
26
26
|
/** Custom API group for the CRD (defaults to 'kro.run' in Kro) */
|
|
27
27
|
group?: string;
|
|
28
|
-
|
|
28
|
+
/** Spec fields — nested objects represent KRO SimpleSchema nested types. */
|
|
29
|
+
spec: Record<string, unknown>;
|
|
29
30
|
/** Status fields may be plain CEL expression strings or nested objects for nested status mappings. */
|
|
30
31
|
status?: Record<string, string | Record<string, unknown>>;
|
|
31
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Ternary conditional metadata — one entry per detected
|
|
35
|
+
* `spec.optionalField ? truthySection : falsySection` expression in a
|
|
36
|
+
* composition. Used during YAML post-processing to replace the truthy
|
|
37
|
+
* section with a CEL `has() ? ... : ''` conditional.
|
|
38
|
+
*/
|
|
39
|
+
export interface TernaryConditional {
|
|
40
|
+
/** Raw marker-containing section emitted when the ternary is truthy. */
|
|
41
|
+
proxySection: string;
|
|
42
|
+
/** Value emitted when the condition is falsy (usually an empty string). */
|
|
43
|
+
falsyValue: string;
|
|
44
|
+
/** Dotted path to the optional spec field that controls the ternary. */
|
|
45
|
+
conditionField: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* KroSimpleSchema augmented with post-processing metadata attached during
|
|
49
|
+
* schema generation. The metadata fields are attached as non-enumerable
|
|
50
|
+
* properties so they don't serialize to YAML, but consumers can still read
|
|
51
|
+
* them in a type-safe way.
|
|
52
|
+
*
|
|
53
|
+
* - `__ternaryConditionals`: Ternary expressions detected via re-execution
|
|
54
|
+
* analysis. Applied to resource bodies before YAML serialization.
|
|
55
|
+
* - `__omitFields`: Optional spec fields without defaults. Applied as
|
|
56
|
+
* `has() ? ... : omit()` wrappers on the YAML string after serialization.
|
|
57
|
+
*/
|
|
58
|
+
export interface KroSimpleSchemaWithMetadata extends KroSimpleSchema {
|
|
59
|
+
readonly __ternaryConditionals?: TernaryConditional[];
|
|
60
|
+
readonly __omitFields?: string[];
|
|
61
|
+
}
|
|
32
62
|
export interface KroFieldDefinition {
|
|
33
63
|
type: string;
|
|
34
64
|
markers?: string;
|
|
@@ -198,6 +228,15 @@ export interface SerializationContext {
|
|
|
198
228
|
celPrefix: string;
|
|
199
229
|
namespace?: string;
|
|
200
230
|
resourceIdStrategy: 'deterministic' | 'random';
|
|
231
|
+
/**
|
|
232
|
+
* Top-level optional spec field names (without `schema.spec.` prefix) that
|
|
233
|
+
* should be wrapped with KRO 0.9+ `has(...) ? ... : omit()` when referenced
|
|
234
|
+
* as a single CEL expression in a resource template. Populated from the
|
|
235
|
+
* schema metadata (`KroSimpleSchemaWithMetadata.__omitFields`). Applied
|
|
236
|
+
* inline during ref-to-CEL conversion so no post-hoc YAML-string rewriting
|
|
237
|
+
* is required.
|
|
238
|
+
*/
|
|
239
|
+
omitFields?: ReadonlySet<string>;
|
|
201
240
|
}
|
|
202
241
|
export interface ResourceDependency {
|
|
203
242
|
from: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/core/types/serialization.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAG/E,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,KAAK,GACN,MAAM,aAAa,CAAC;AAMrB,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,IAAI,EAAE,yBAAyB,CAAC;IAChC,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IACrF,IAAI,EAAE;QACJ,MAAM,EAAE,eAAe,CAAC;QACxB,SAAS,EAAE,mBAAmB,EAAE,CAAC;KAClC,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../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,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,gFAAgF;IAChF,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cel-validator.d.ts","sourceRoot":"","sources":["../../../src/core/validation/cel-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAgCnF;
|
|
1
|
+
{"version":3,"file":"cel-validator.d.ts","sourceRoot":"","sources":["../../../src/core/validation/cel-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAgCnF;AA4GD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC7E,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC,CAoCA;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAC5C,mBAAmB,CAoGrB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAC5C,mBAAmB,CAqBrB;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC7C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,mBAAmB,CAWrB"}
|
|
@@ -37,47 +37,73 @@ export function validateResourceId(id) {
|
|
|
37
37
|
return { isValid: true };
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Check if a CEL expression string references any non-schema resource fields.
|
|
41
|
+
*
|
|
42
|
+
* Any reference to a deployed resource (status, metadata, or spec) requires
|
|
43
|
+
* KRO runtime resolution because:
|
|
44
|
+
* - `resource.status.*` — populated by the cluster after deployment
|
|
45
|
+
* - `resource.metadata.*` — set by K8s (may include generated fields like uid)
|
|
46
|
+
* - `resource.spec.*` — available on the deployed resource object
|
|
47
|
+
*
|
|
48
|
+
* Only `schema.spec.*` references are static (resolved from the user's spec
|
|
49
|
+
* by TypeKro at deploy time). KRO status CEL does NOT support `schema.spec.*`.
|
|
41
50
|
*/
|
|
42
|
-
function
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
// and resources namespace references (resources.deployment.status.field)
|
|
46
|
-
const hasResourceReferences = /\b(resources\.\w+|\w+\.status\.|\.metadata\.)/.test(expression);
|
|
47
|
-
// Check if the expression contains schema references
|
|
48
|
-
const hasSchemaReferences = /\bschema\./.test(expression);
|
|
49
|
-
// If it has resource references, it needs Kro resolution (mixed or resource-only)
|
|
50
|
-
if (hasResourceReferences) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
// If it has schema references but no resource references, it can be hydrated by TypeKro
|
|
54
|
-
if (hasSchemaReferences) {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
// If it has neither schema nor resource references, it's a static expression
|
|
58
|
-
// that can be hydrated by TypeKro
|
|
59
|
-
return true;
|
|
51
|
+
function containsNonSchemaResourceReferences(expression) {
|
|
52
|
+
// Match `identifier.(status|metadata|spec).field` but NOT `schema.*`
|
|
53
|
+
return /\b(?!schema\.)\w+\.(status|metadata|spec)\./.test(expression);
|
|
60
54
|
}
|
|
61
55
|
/**
|
|
62
|
-
* Determines if a status field value requires Kro resolution
|
|
56
|
+
* Determines if a status field value requires Kro resolution.
|
|
57
|
+
*
|
|
58
|
+
* A value requires KRO resolution if it references any non-schema resource
|
|
59
|
+
* field (status, metadata, or spec). Schema refs and literal values are
|
|
60
|
+
* static — they can be hydrated by the TypeKro runtime at deploy time.
|
|
63
61
|
*/
|
|
64
62
|
function requiresKroResolution(value) {
|
|
65
63
|
if (isKubernetesRef(value)) {
|
|
66
|
-
// Schema
|
|
67
|
-
// because Kro controller doesn't have access to the 'schema' variable
|
|
64
|
+
// Schema refs are static — resolved from the user's spec at deploy time.
|
|
68
65
|
if (value.resourceId === '__schema__') {
|
|
69
66
|
return false;
|
|
70
67
|
}
|
|
71
|
-
|
|
68
|
+
// Determine which fields require KRO runtime resolution vs. can be hydrated
|
|
69
|
+
// by TypeKro at deploy time.
|
|
70
|
+
//
|
|
71
|
+
// Dynamic (KRO resolves):
|
|
72
|
+
// - status.* — only available after deployment
|
|
73
|
+
// - metadata.uid — assigned by API server
|
|
74
|
+
// - metadata.creationTimestamp — assigned by API server
|
|
75
|
+
// - metadata.resourceVersion — assigned by API server
|
|
76
|
+
// - metadata.generation — assigned by API server
|
|
77
|
+
//
|
|
78
|
+
// Static (TypeKro resolves at deploy time):
|
|
79
|
+
// - spec.* — deterministic from the template
|
|
80
|
+
// - metadata.name — set by the composition
|
|
81
|
+
// - metadata.namespace — set by the composition
|
|
82
|
+
// - metadata.labels — set by the composition
|
|
83
|
+
// - metadata.annotations — set by the composition
|
|
84
|
+
if (typeof value.fieldPath !== 'string')
|
|
85
|
+
return false;
|
|
86
|
+
if (value.fieldPath.startsWith('status.'))
|
|
87
|
+
return true;
|
|
88
|
+
if (value.fieldPath.startsWith('metadata.')) {
|
|
89
|
+
const staticMetadataFields = ['metadata.name', 'metadata.namespace', 'metadata.labels', 'metadata.annotations'];
|
|
90
|
+
return !staticMetadataFields.some(f => value.fieldPath === f || value.fieldPath.startsWith(`${f}.`));
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
72
93
|
}
|
|
73
94
|
if (isCelExpression(value)) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
95
|
+
return containsNonSchemaResourceReferences(value.expression);
|
|
96
|
+
}
|
|
97
|
+
// Strings containing __KUBERNETES_REF__ markers from template literals
|
|
98
|
+
if (typeof value === 'string' && value.includes('__KUBERNETES_REF_')) {
|
|
99
|
+
const refPattern = /__KUBERNETES_REF_(__schema__|[^_]+)_([a-zA-Z0-9.$]+)__/g;
|
|
100
|
+
let match = refPattern.exec(value);
|
|
101
|
+
while (match !== null) {
|
|
102
|
+
if (match[1] !== '__schema__')
|
|
103
|
+
return true;
|
|
104
|
+
match = refPattern.exec(value);
|
|
78
105
|
}
|
|
79
|
-
|
|
80
|
-
return true;
|
|
106
|
+
return false;
|
|
81
107
|
}
|
|
82
108
|
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
83
109
|
// Recursively check nested objects
|
|
@@ -221,9 +247,7 @@ export function validateStatusCelExpressions(statusMappings, resources) {
|
|
|
221
247
|
for (const [fieldName, fieldValue] of Object.entries(dynamicFields)) {
|
|
222
248
|
validateExpression(fieldName, fieldValue);
|
|
223
249
|
}
|
|
224
|
-
// Log info about field separation for debugging
|
|
225
250
|
const staticFieldNames = Object.keys(staticFields);
|
|
226
|
-
const _dynamicFieldNames = Object.keys(dynamicFields);
|
|
227
251
|
if (staticFieldNames.length > 0) {
|
|
228
252
|
warnings.push({
|
|
229
253
|
field: 'status',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cel-validator.js","sourceRoot":"","sources":["../../../src/core/validation/cel-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAgB9E;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAU;IAC3C,8EAA8E;IAC9E,MAAM,cAAc,GAAG,qBAAqB,CAAC;IAE7C,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAC7B,IAAI,UAAU,GAAG,EAAE,CAAC;QAEpB,kCAAkC;QAClC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,UAAU,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,gCAAgC;QAChC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,UAAU,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,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ACrC,CAAC,CAAC,4BAA4B,CAAC,cAAc,EAAE,SAAS,CAAC;QACzD,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAEhD,OAAO;QACL,OAAO,EAAE,oBAAoB,CAAC,OAAO,IAAI,gBAAgB,CAAC,OAAO;QACjE,MAAM,EAAE,CAAC,GAAG,oBAAoB,CAAC,MAAM,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC;QACpE,QAAQ,EAAE,CAAC,GAAG,oBAAoB,CAAC,QAAQ,EAAE,GAAG,gBAAgB,CAAC,QAAQ,CAAC;KAC3E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG Operator Bootstrap Composition
|
|
3
|
+
*
|
|
4
|
+
* Deploys the CloudNativePG operator via HelmRepository and HelmRelease resources.
|
|
5
|
+
* The operator manages PostgreSQL clusters as Kubernetes-native resources.
|
|
6
|
+
*
|
|
7
|
+
* This composition:
|
|
8
|
+
* 1. Creates the target namespace
|
|
9
|
+
* 2. Creates a HelmRepository pointing to the CNPG chart repo
|
|
10
|
+
* 3. Creates a HelmRelease that installs the operator
|
|
11
|
+
*
|
|
12
|
+
* After the operator is running, use the `cluster()`, `backup()`,
|
|
13
|
+
* `scheduledBackup()`, and `pooler()` factories to create database resources.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const cnpgFactory = cnpgBootstrap.factory('kro', {
|
|
18
|
+
* namespace: 'cnpg-system',
|
|
19
|
+
* waitForReady: true,
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* await cnpgFactory.deploy({
|
|
23
|
+
* name: 'cnpg',
|
|
24
|
+
* namespace: 'cnpg-system',
|
|
25
|
+
* version: '0.23.0',
|
|
26
|
+
* installCRDs: true,
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const cnpgBootstrap: import("../../../index.js").CallableComposition<{
|
|
31
|
+
name: string;
|
|
32
|
+
namespace?: string;
|
|
33
|
+
version?: string;
|
|
34
|
+
installCRDs?: boolean;
|
|
35
|
+
replicaCount?: number;
|
|
36
|
+
monitoring?: {
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
};
|
|
39
|
+
resources?: {
|
|
40
|
+
requests?: {
|
|
41
|
+
cpu?: string;
|
|
42
|
+
memory?: string;
|
|
43
|
+
};
|
|
44
|
+
limits?: {
|
|
45
|
+
cpu?: string;
|
|
46
|
+
memory?: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
customValues?: Record<string, unknown>;
|
|
50
|
+
}, {
|
|
51
|
+
phase: "Ready" | "Installing";
|
|
52
|
+
ready: boolean;
|
|
53
|
+
version?: string;
|
|
54
|
+
}>;
|
|
55
|
+
//# sourceMappingURL=cnpg-bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cnpg-bootstrap.d.ts","sourceRoot":"","sources":["../../../../src/factories/cnpg/compositions/cnpg-bootstrap.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;EAoEzB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { kubernetesComposition } from '../../../core/composition/imperative.js';
|
|
2
|
+
import { DEFAULT_FLUX_NAMESPACE } from '../../../core/config/defaults.js';
|
|
3
|
+
import { Cel } from '../../../core/references/cel.js';
|
|
4
|
+
import { namespace } from '../../kubernetes/core/namespace.js';
|
|
5
|
+
import { cnpgHelmRelease, cnpgHelmRepository } from '../resources/helm.js';
|
|
6
|
+
import { CnpgBootstrapConfigSchema, CnpgBootstrapStatusSchema, } from '../types.js';
|
|
7
|
+
import { mapCnpgConfigToHelmValues } from '../utils/helm-values-mapper.js';
|
|
8
|
+
/**
|
|
9
|
+
* CloudNativePG Operator Bootstrap Composition
|
|
10
|
+
*
|
|
11
|
+
* Deploys the CloudNativePG operator via HelmRepository and HelmRelease resources.
|
|
12
|
+
* The operator manages PostgreSQL clusters as Kubernetes-native resources.
|
|
13
|
+
*
|
|
14
|
+
* This composition:
|
|
15
|
+
* 1. Creates the target namespace
|
|
16
|
+
* 2. Creates a HelmRepository pointing to the CNPG chart repo
|
|
17
|
+
* 3. Creates a HelmRelease that installs the operator
|
|
18
|
+
*
|
|
19
|
+
* After the operator is running, use the `cluster()`, `backup()`,
|
|
20
|
+
* `scheduledBackup()`, and `pooler()` factories to create database resources.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const cnpgFactory = cnpgBootstrap.factory('kro', {
|
|
25
|
+
* namespace: 'cnpg-system',
|
|
26
|
+
* waitForReady: true,
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* await cnpgFactory.deploy({
|
|
30
|
+
* name: 'cnpg',
|
|
31
|
+
* namespace: 'cnpg-system',
|
|
32
|
+
* version: '0.23.0',
|
|
33
|
+
* installCRDs: true,
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const cnpgBootstrap = kubernetesComposition({
|
|
38
|
+
name: 'cnpg-bootstrap',
|
|
39
|
+
kind: 'CnpgBootstrap',
|
|
40
|
+
spec: CnpgBootstrapConfigSchema,
|
|
41
|
+
status: CnpgBootstrapStatusSchema,
|
|
42
|
+
}, (spec) => {
|
|
43
|
+
const resolvedNamespace = spec.namespace || 'cnpg-system';
|
|
44
|
+
const resolvedVersion = spec.version || '0.23.0';
|
|
45
|
+
// Map config to Helm values
|
|
46
|
+
const helmValues = mapCnpgConfigToHelmValues({
|
|
47
|
+
...spec,
|
|
48
|
+
namespace: resolvedNamespace,
|
|
49
|
+
version: resolvedVersion,
|
|
50
|
+
});
|
|
51
|
+
// Resources are _-prefixed because they're registered via side effects in the
|
|
52
|
+
// kubernetesComposition callback — the composition captures them automatically.
|
|
53
|
+
// They're referenced in the status return via their `id`.
|
|
54
|
+
const _cnpgNamespace = namespace({
|
|
55
|
+
metadata: {
|
|
56
|
+
name: resolvedNamespace,
|
|
57
|
+
labels: {
|
|
58
|
+
'app.kubernetes.io/name': 'cloudnative-pg',
|
|
59
|
+
'app.kubernetes.io/instance': spec.name,
|
|
60
|
+
'app.kubernetes.io/version': resolvedVersion,
|
|
61
|
+
'app.kubernetes.io/managed-by': 'typekro',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
id: 'cnpgNamespace',
|
|
65
|
+
});
|
|
66
|
+
// Create HelmRepository for CNPG charts
|
|
67
|
+
const _helmRepository = cnpgHelmRepository({
|
|
68
|
+
name: 'cnpg-repo',
|
|
69
|
+
namespace: DEFAULT_FLUX_NAMESPACE,
|
|
70
|
+
id: 'cnpgHelmRepository',
|
|
71
|
+
});
|
|
72
|
+
// Create HelmRelease for the CNPG operator
|
|
73
|
+
const _helmRelease = cnpgHelmRelease({
|
|
74
|
+
name: spec.name,
|
|
75
|
+
namespace: resolvedNamespace,
|
|
76
|
+
version: resolvedVersion,
|
|
77
|
+
values: helmValues,
|
|
78
|
+
repositoryName: 'cnpg-repo',
|
|
79
|
+
id: 'cnpgHelmRelease',
|
|
80
|
+
});
|
|
81
|
+
// Status derived from HelmRelease conditions.
|
|
82
|
+
// Flux HelmRelease v2 uses conditions with type='Ready' for readiness.
|
|
83
|
+
return {
|
|
84
|
+
ready: Cel.expr(_helmRelease.status.conditions, '.exists(c, c.type == "Ready" && c.status == "True")'),
|
|
85
|
+
// Two-state phase: nested ternaries with .exists() require repeating the
|
|
86
|
+
// full resource path in CEL, which Cel.expr(ref, operator) cannot express.
|
|
87
|
+
// The second .exists() lacks a receiver and produces invalid CEL.
|
|
88
|
+
phase: Cel.expr(_helmRelease.status.conditions, '.exists(c, c.type == "Ready" && c.status == "True") ? "Ready" : "Installing"'),
|
|
89
|
+
version: resolvedVersion,
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=cnpg-bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cnpg-bootstrap.js","sourceRoot":"","sources":["../../../../src/factories/cnpg/compositions/cnpg-bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAEL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,qBAAqB,CAChD;IACE,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,yBAAyB;IAC/B,MAAM,EAAE,yBAAyB;CAClC,EACD,CAAC,IAAyB,EAAE,EAAE;IAC5B,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,IAAI,aAAa,CAAC;IAC1D,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC;IAEjD,4BAA4B;IAC5B,MAAM,UAAU,GAAG,yBAAyB,CAAC;QAC3C,GAAG,IAAI;QACP,SAAS,EAAE,iBAAiB;QAC5B,OAAO,EAAE,eAAe;KACzB,CAAC,CAAC;IAEH,8EAA8E;IAC9E,gFAAgF;IAChF,0DAA0D;IAC1D,MAAM,cAAc,GAAG,SAAS,CAAC;QAC/B,QAAQ,EAAE;YACR,IAAI,EAAE,iBAAiB;YACvB,MAAM,EAAE;gBACN,wBAAwB,EAAE,gBAAgB;gBAC1C,4BAA4B,EAAE,IAAI,CAAC,IAAI;gBACvC,2BAA2B,EAAE,eAAe;gBAC5C,8BAA8B,EAAE,SAAS;aAC1C;SACF;QACD,EAAE,EAAE,eAAe;KACpB,CAAC,CAAC;IAEH,wCAAwC;IACxC,MAAM,eAAe,GAAG,kBAAkB,CAAC;QACzC,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,sBAAsB;QACjC,EAAE,EAAE,oBAAoB;KACzB,CAAC,CAAC;IAEH,2CAA2C;IAC3C,MAAM,YAAY,GAAG,eAAe,CAAC;QACnC,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,SAAS,EAAE,iBAAiB;QAC5B,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE,UAAU;QAClB,cAAc,EAAE,WAAW;QAC3B,EAAE,EAAE,iBAAiB;KACtB,CAAC,CAAC;IAEH,8CAA8C;IAC9C,uEAAuE;IACvE,OAAO;QACL,KAAK,EAAE,GAAG,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,UAAU,EAC9B,qDAAqD,CACtD;QACD,yEAAyE;QACzE,2EAA2E;QAC3E,kEAAkE;QAClE,KAAK,EAAE,GAAG,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,UAAU,EAC9B,8EAA8E,CAC/E;QACD,OAAO,EAAE,eAAe;KACzB,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/factories/cnpg/compositions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/factories/cnpg/compositions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG (CNPG) Integration for TypeKro
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe factories for managing PostgreSQL clusters on Kubernetes
|
|
5
|
+
* using the CloudNativePG operator.
|
|
6
|
+
*
|
|
7
|
+
* ## Resources
|
|
8
|
+
* - `cluster()` — PostgreSQL cluster (primary + replicas)
|
|
9
|
+
* - `backup()` — On-demand backup
|
|
10
|
+
* - `scheduledBackup()` — Cron-based automated backups
|
|
11
|
+
* - `pooler()` — PgBouncer connection pooling
|
|
12
|
+
* - `cnpgHelmRepository()` — Helm chart repository
|
|
13
|
+
* - `cnpgHelmRelease()` — Operator installation via Helm
|
|
14
|
+
*
|
|
15
|
+
* ## Compositions
|
|
16
|
+
* - `cnpgBootstrap` — Complete operator deployment (namespace + Helm repo + release)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { cnpgBootstrap, cluster, scheduledBackup } from 'typekro/cnpg';
|
|
21
|
+
*
|
|
22
|
+
* // Install the operator
|
|
23
|
+
* const operatorFactory = cnpgBootstrap.factory('kro', { namespace: 'cnpg-system' });
|
|
24
|
+
* await operatorFactory.deploy({ name: 'cnpg', namespace: 'cnpg-system' });
|
|
25
|
+
*
|
|
26
|
+
* // Create a PostgreSQL cluster
|
|
27
|
+
* const db = cluster({
|
|
28
|
+
* name: 'my-db',
|
|
29
|
+
* namespace: 'default',
|
|
30
|
+
* spec: { instances: 3, storage: { size: '50Gi' } },
|
|
31
|
+
* id: 'myDatabase',
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @see https://cloudnative-pg.io/documentation/
|
|
36
|
+
* @module
|
|
37
|
+
*/
|
|
38
|
+
export * from './compositions/index.js';
|
|
39
|
+
export * from './resources/index.js';
|
|
40
|
+
export * from './types.js';
|
|
41
|
+
export * from './utils/index.js';
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/factories/cnpg/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG (CNPG) Integration for TypeKro
|
|
3
|
+
*
|
|
4
|
+
* Provides type-safe factories for managing PostgreSQL clusters on Kubernetes
|
|
5
|
+
* using the CloudNativePG operator.
|
|
6
|
+
*
|
|
7
|
+
* ## Resources
|
|
8
|
+
* - `cluster()` — PostgreSQL cluster (primary + replicas)
|
|
9
|
+
* - `backup()` — On-demand backup
|
|
10
|
+
* - `scheduledBackup()` — Cron-based automated backups
|
|
11
|
+
* - `pooler()` — PgBouncer connection pooling
|
|
12
|
+
* - `cnpgHelmRepository()` — Helm chart repository
|
|
13
|
+
* - `cnpgHelmRelease()` — Operator installation via Helm
|
|
14
|
+
*
|
|
15
|
+
* ## Compositions
|
|
16
|
+
* - `cnpgBootstrap` — Complete operator deployment (namespace + Helm repo + release)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { cnpgBootstrap, cluster, scheduledBackup } from 'typekro/cnpg';
|
|
21
|
+
*
|
|
22
|
+
* // Install the operator
|
|
23
|
+
* const operatorFactory = cnpgBootstrap.factory('kro', { namespace: 'cnpg-system' });
|
|
24
|
+
* await operatorFactory.deploy({ name: 'cnpg', namespace: 'cnpg-system' });
|
|
25
|
+
*
|
|
26
|
+
* // Create a PostgreSQL cluster
|
|
27
|
+
* const db = cluster({
|
|
28
|
+
* name: 'my-db',
|
|
29
|
+
* namespace: 'default',
|
|
30
|
+
* spec: { instances: 3, storage: { size: '50Gi' } },
|
|
31
|
+
* id: 'myDatabase',
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @see https://cloudnative-pg.io/documentation/
|
|
36
|
+
* @module
|
|
37
|
+
*/
|
|
38
|
+
export * from './compositions/index.js';
|
|
39
|
+
export * from './resources/index.js';
|
|
40
|
+
export * from './types.js';
|
|
41
|
+
export * from './utils/index.js';
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/factories/cnpg/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG Backup Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates a CNPG Backup resource for on-demand PostgreSQL backups.
|
|
5
|
+
*/
|
|
6
|
+
import type { Composable, Enhanced } from '../../../core/types/index.js';
|
|
7
|
+
import type { BackupConfig, BackupStatus } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* CloudNativePG Backup Factory
|
|
10
|
+
*
|
|
11
|
+
* Creates an on-demand backup of a PostgreSQL cluster. Supports both
|
|
12
|
+
* barman object store and volume snapshot methods.
|
|
13
|
+
*
|
|
14
|
+
* @param config - Backup configuration following postgresql.cnpg.io/v1 API
|
|
15
|
+
* @returns Enhanced Backup resource with readiness evaluation
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const bk = backup({
|
|
20
|
+
* name: 'manual-backup-20240115',
|
|
21
|
+
* namespace: 'databases',
|
|
22
|
+
* spec: {
|
|
23
|
+
* cluster: { name: 'my-database' },
|
|
24
|
+
* method: 'barmanObjectStore',
|
|
25
|
+
* target: 'prefer-standby',
|
|
26
|
+
* },
|
|
27
|
+
* id: 'manualBackup',
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare function createBackupResource(config: Composable<BackupConfig>): Enhanced<BackupConfig['spec'], BackupStatus>;
|
|
32
|
+
export declare const backup: typeof createBackupResource;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=backup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../../../../src/factories/cnpg/resources/backup.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;AAqD9D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,oBAAoB,CAC3B,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,GAC/B,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CAiB9C;AAED,eAAO,MAAM,MAAM,6BAAuB,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudNativePG Backup Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates a CNPG Backup resource for on-demand PostgreSQL backups.
|
|
5
|
+
*/
|
|
6
|
+
import { createResource } from '../../shared.js';
|
|
7
|
+
/**
|
|
8
|
+
* Backup Readiness Evaluator
|
|
9
|
+
*
|
|
10
|
+
* CNPG Backups use a phase-based status model rather than conditions.
|
|
11
|
+
* Phases: new → started → completed (or failed).
|
|
12
|
+
*/
|
|
13
|
+
function backupReadinessEvaluator(liveResource) {
|
|
14
|
+
const resource = liveResource;
|
|
15
|
+
const status = resource?.status;
|
|
16
|
+
if (!status) {
|
|
17
|
+
return {
|
|
18
|
+
ready: false,
|
|
19
|
+
message: 'Backup has no status yet',
|
|
20
|
+
reason: 'StatusMissing',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const phase = status.phase;
|
|
24
|
+
if (phase === 'completed') {
|
|
25
|
+
return {
|
|
26
|
+
ready: true,
|
|
27
|
+
message: `Backup completed at ${status.stoppedAt || 'unknown time'}`,
|
|
28
|
+
reason: 'Completed',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (phase === 'failed') {
|
|
32
|
+
return {
|
|
33
|
+
ready: false,
|
|
34
|
+
message: `Backup failed: ${status.error || 'unknown error'}`,
|
|
35
|
+
reason: 'Failed',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (phase === 'started') {
|
|
39
|
+
return {
|
|
40
|
+
ready: false,
|
|
41
|
+
message: `Backup in progress since ${status.startedAt || 'unknown time'}`,
|
|
42
|
+
reason: 'InProgress',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
ready: false,
|
|
47
|
+
message: `Backup is pending (phase: ${phase || 'unknown'})`,
|
|
48
|
+
reason: 'Pending',
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* CloudNativePG Backup Factory
|
|
53
|
+
*
|
|
54
|
+
* Creates an on-demand backup of a PostgreSQL cluster. Supports both
|
|
55
|
+
* barman object store and volume snapshot methods.
|
|
56
|
+
*
|
|
57
|
+
* @param config - Backup configuration following postgresql.cnpg.io/v1 API
|
|
58
|
+
* @returns Enhanced Backup resource with readiness evaluation
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const bk = backup({
|
|
63
|
+
* name: 'manual-backup-20240115',
|
|
64
|
+
* namespace: 'databases',
|
|
65
|
+
* spec: {
|
|
66
|
+
* cluster: { name: 'my-database' },
|
|
67
|
+
* method: 'barmanObjectStore',
|
|
68
|
+
* target: 'prefer-standby',
|
|
69
|
+
* },
|
|
70
|
+
* id: 'manualBackup',
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
function createBackupResource(config) {
|
|
75
|
+
return createResource({
|
|
76
|
+
apiVersion: 'postgresql.cnpg.io/v1',
|
|
77
|
+
kind: 'Backup',
|
|
78
|
+
metadata: {
|
|
79
|
+
name: config.name,
|
|
80
|
+
...(config.namespace && { namespace: config.namespace }),
|
|
81
|
+
},
|
|
82
|
+
spec: config.spec,
|
|
83
|
+
...(config.id && { id: config.id }),
|
|
84
|
+
}, { scope: 'namespaced' }).withReadinessEvaluator(backupReadinessEvaluator);
|
|
85
|
+
}
|
|
86
|
+
export const backup = createBackupResource;
|
|
87
|
+
//# sourceMappingURL=backup.js.map
|