@ankhorage/kubernetes 0.8.2 → 0.9.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/README.md +1 -1
- package/dist/features/workload-reconciliation/adapters/createKubectlKubernetesApi.d.ts +2 -2
- package/dist/features/workload-reconciliation/adapters/createKubectlKubernetesApi.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/adapters/createKubectlKubernetesApi.js +3 -3
- package/dist/features/workload-reconciliation/adapters/createKubectlKubernetesApi.js.map +1 -1
- package/dist/features/workload-reconciliation/adapters/createSubprocessKubernetesCommandRunner.d.ts +1 -1
- package/dist/features/workload-reconciliation/adapters/createSubprocessKubernetesCommandRunner.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/adapters/createSubprocessKubernetesCommandRunner.js.map +1 -1
- package/dist/features/workload-reconciliation/adapters/kubectlResource.d.ts +1 -1
- package/dist/features/workload-reconciliation/adapters/kubectlResource.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/adapters/kubectlResource.js.map +1 -1
- package/dist/features/workload-reconciliation/adapters/observeKubectlDeploymentPodFailureAsync.d.ts +2 -2
- package/dist/features/workload-reconciliation/adapters/observeKubectlDeploymentPodFailureAsync.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/adapters/observeKubectlDeploymentPodFailureAsync.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesController.d.ts +2 -2
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesController.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesController.js +2 -2
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesController.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesExposure.d.ts +2 -2
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesExposure.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesExposure.js +2 -2
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesExposure.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.d.ts +2 -2
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.js +3 -3
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.d.ts +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.js +3 -3
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.d.ts +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.js +3 -3
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.d.ts +2 -2
- package/dist/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.js +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.d.ts +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.js +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.d.ts +2 -2
- package/dist/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.js +8 -8
- package/dist/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.d.ts +2 -2
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.js +5 -5
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.d.ts +2 -2
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.js +5 -5
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.d.ts +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.js +5 -5
- package/dist/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/removeKubernetesResourcesAsync.d.ts +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/removeKubernetesResourcesAsync.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/removeKubernetesResourcesAsync.js +4 -4
- package/dist/features/workload-reconciliation/application/use-cases/removeKubernetesResourcesAsync.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/resolveKubernetesWorkloadValues.d.ts +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/resolveKubernetesWorkloadValues.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/resolveKubernetesWorkloadValues.js +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/resolveKubernetesWorkloadValues.js.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/waitForKubernetesReadinessAsync.d.ts +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/waitForKubernetesReadinessAsync.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/application/use-cases/waitForKubernetesReadinessAsync.js +3 -3
- package/dist/features/workload-reconciliation/application/use-cases/waitForKubernetesReadinessAsync.js.map +1 -1
- package/dist/features/workload-reconciliation/composition/createKubernetesDriver.d.ts +1 -1
- package/dist/features/workload-reconciliation/composition/createKubernetesDriver.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/composition/createKubernetesDriver.js +7 -7
- package/dist/features/workload-reconciliation/composition/createKubernetesDriver.js.map +1 -1
- package/dist/features/workload-reconciliation/utils/areKubernetesResourcesEquivalent.d.ts +1 -1
- package/dist/features/workload-reconciliation/utils/areKubernetesResourcesEquivalent.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/utils/areKubernetesResourcesEquivalent.js.map +1 -1
- package/dist/features/workload-reconciliation/utils/createKubernetesDesiredResource.d.ts +2 -2
- package/dist/features/workload-reconciliation/utils/createKubernetesDesiredResource.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/utils/createKubernetesDesiredResource.js +4 -4
- package/dist/features/workload-reconciliation/utils/createKubernetesDesiredResource.js.map +1 -1
- package/dist/features/workload-reconciliation/utils/createKubernetesIdentity.d.ts +1 -1
- package/dist/features/workload-reconciliation/utils/createKubernetesIdentity.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/utils/createKubernetesIdentity.js.map +1 -1
- package/dist/features/workload-reconciliation/utils/getKubernetesOwnershipQuery.d.ts +2 -2
- package/dist/features/workload-reconciliation/utils/getKubernetesOwnershipQuery.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/utils/getKubernetesOwnershipQuery.js +2 -2
- package/dist/features/workload-reconciliation/utils/getKubernetesOwnershipQuery.js.map +1 -1
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceKey.d.ts +1 -1
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceKey.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceKey.js.map +1 -1
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceReference.d.ts +1 -1
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceReference.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceReference.js.map +1 -1
- package/dist/features/workload-reconciliation/utils/readKubernetesOwnedResource.d.ts +2 -2
- package/dist/features/workload-reconciliation/utils/readKubernetesOwnedResource.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/utils/readKubernetesOwnedResource.js +3 -3
- package/dist/features/workload-reconciliation/utils/readKubernetesOwnedResource.js.map +1 -1
- package/dist/features/workload-reconciliation/utils/sortKubernetesResourcesForRemoval.d.ts +1 -1
- package/dist/features/workload-reconciliation/utils/sortKubernetesResourcesForRemoval.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/utils/sortKubernetesResourcesForRemoval.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/types/kubectl.d.ts +1 -1
- package/dist/types/kubectl.d.ts.map +1 -1
- package/dist/types/kubectl.js.map +1 -1
- package/dist/types/kubernetesDriver.d.ts +1 -1
- package/dist/types/kubernetesDriver.d.ts.map +1 -1
- package/dist/types/kubernetesDriver.js.map +1 -1
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createKubernetesPrerequisites.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,+BAA+B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createKubernetesPrerequisites.js","sourceRoot":"","sources":["../../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,UAAU,EAAE;gBAC3C,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,MAAM,EAAE,EAAE;gBACV,WAAW,EAAE,EAAE;aAChB;YACD,IAAI,EAAE;gBACJ,WAAW,EAAE,CAAC,eAAe,CAAC;gBAC9B,SAAS,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE;aAC5D;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { InfraResourceIdentity, InfraWorkloadSpec } from '@ankhorage/contracts/infra';\n\nimport type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';\nimport type {\n KubernetesDesiredResource,\n KubernetesResolvedWorkloadValues,\n KubernetesSecretBinding,\n} from '../../../../types/kubernetesResources.js';\nimport { createKubernetesDesiredResource } from '../../utils/createKubernetesDesiredResource.js';\nimport { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference.js';\nimport { toKubernetesName } from '../../utils/toKubernetesName.js';\n\n/*** Create config, secret and persistent-volume prerequisites in dependency order. */\nexport function createKubernetesPrerequisites(\n request: KubernetesDriverRequest,\n input: CreateKubernetesPrerequisitesInput,\n): KubernetesPrerequisites {\n const resources: KubernetesDesiredResource[] = [];\n const owners: InfraResourceIdentity[] = [input.namespaceOwner];\n const configMap = createConfigMap(request, input);\n if (configMap !== undefined) {\n resources.push(configMap);\n owners.push(configMap.owner.identity);\n }\n const secret = createSecret(request, input);\n if (secret !== undefined) {\n resources.push(secret.resource);\n owners.push(secret.resource.owner.identity);\n }\n for (const [, volume] of Object.entries(input.workload.persistence ?? {}).sort(\n ([left], [right]) => left.localeCompare(right),\n )) {\n const claim = createPersistentVolumeClaim(request, input, volume);\n resources.push(claim);\n owners.push(claim.owner.identity);\n }\n return { resources, owners, secretBindings: secret?.bindings ?? [] };\n}\n\nexport interface CreateKubernetesPrerequisitesInput {\n readonly namespace: string;\n readonly namespaceOwner: InfraResourceIdentity;\n readonly workloadName: string;\n readonly workload: InfraWorkloadSpec;\n readonly values: KubernetesResolvedWorkloadValues;\n}\n\nexport interface KubernetesPrerequisites {\n readonly resources: readonly KubernetesDesiredResource[];\n readonly owners: readonly InfraResourceIdentity[];\n readonly secretBindings: readonly KubernetesSecretBinding[];\n}\n\n/*** Create portable file configuration without secret content. */\nfunction createConfigMap(\n request: KubernetesDriverRequest,\n input: CreateKubernetesPrerequisitesInput,\n): KubernetesDesiredResource | undefined {\n if (Object.keys(input.values.files).length === 0) return undefined;\n const data = Object.fromEntries(\n Object.values(input.values.files).map((value, index) => [`file-${index}`, value]),\n );\n return createKubernetesDesiredResource(request, {\n resourceId: `config:${input.workloadName}`,\n dependsOn: [input.namespaceOwner],\n resource: {\n apiVersion: 'v1',\n kind: 'ConfigMap',\n metadata: {\n name: `${input.workloadName}-config`,\n namespace: input.namespace,\n labels: {},\n annotations: {},\n },\n data,\n },\n });\n}\n\n/*** Create a value-free Secret skeleton plus runtime-only materialization bindings. */\nfunction createSecret(\n request: KubernetesDriverRequest,\n input: CreateKubernetesPrerequisitesInput,\n):\n | {\n readonly resource: KubernetesDesiredResource;\n readonly bindings: readonly KubernetesSecretBinding[];\n }\n | undefined {\n if (input.values.secrets.length === 0) return undefined;\n const resource = createKubernetesDesiredResource(request, {\n resourceId: `secret:${input.workloadName}`,\n dependsOn: [input.namespaceOwner],\n resource: {\n apiVersion: 'v1',\n kind: 'Secret',\n metadata: {\n name: `${input.workloadName}-secrets`,\n namespace: input.namespace,\n labels: {},\n annotations: {},\n },\n },\n });\n const reference = getKubernetesResourceReference(resource.resource);\n return {\n resource,\n bindings: input.values.secrets.map((secret) => ({\n resource: reference,\n key: secret.key,\n segments: secret.segments,\n })),\n };\n}\n\n/*** Create one persistent volume claim from portable capacity and retention intent. */\nfunction createPersistentVolumeClaim(\n request: KubernetesDriverRequest,\n input: CreateKubernetesPrerequisitesInput,\n volume: NonNullable<InfraWorkloadSpec['persistence']>[string],\n): KubernetesDesiredResource {\n const volumeName = toKubernetesName(volume.id);\n return createKubernetesDesiredResource(request, {\n resourceId: `volume:${input.workloadName}:${volume.id}`,\n persistent: true,\n retention: volume.retention,\n dependsOn: [input.namespaceOwner],\n resource: {\n apiVersion: 'v1',\n kind: 'PersistentVolumeClaim',\n metadata: {\n name: `${input.workloadName}-${volumeName}`,\n namespace: input.namespace,\n labels: {},\n annotations: {},\n },\n spec: {\n accessModes: ['ReadWriteOnce'],\n resources: { requests: { storage: `${volume.sizeGiB}Gi` } },\n },\n },\n });\n}\n"]}
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraOutput, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
2
|
+
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';
|
|
3
3
|
/*** Read safe public outputs exposed by Infra-owned Kubernetes resources. */
|
|
4
4
|
export declare function getKubernetesOutputsAsync(options: KubernetesDriverOptions, request: KubernetesDriverRequest): Promise<InfraResult<readonly InfraOutput[]>>;
|
|
5
5
|
//# sourceMappingURL=getKubernetesOutputsAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getKubernetesOutputsAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"getKubernetesOutputsAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAK/C,6EAA6E;AAC7E,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,WAAW,CAAC,SAAS,WAAW,EAAE,CAAC,CAAC,CA8B9C"}
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery';
|
|
2
|
-
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';
|
|
3
|
-
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource';
|
|
1
|
+
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery.js';
|
|
2
|
+
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference.js';
|
|
3
|
+
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource.js';
|
|
4
4
|
/*** Read safe public outputs exposed by Infra-owned Kubernetes resources. */
|
|
5
5
|
export async function getKubernetesOutputsAsync(options, request) {
|
|
6
6
|
try {
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getKubernetesOutputsAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,2BAA2B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getKubernetesOutputsAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,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BACX;oBACE,QAAQ,EAAE,OAAO;oBACjB,IAAI,EAAE,2BAA2B;oBACjC,OAAO,EAAE,8CAA8C;iBACxD;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { InfraOutput, InfraResult } from '@ankhorage/contracts/infra';\n\nimport type {\n KubernetesDriverOptions,\n KubernetesDriverRequest,\n} from '../../../../types/kubernetesDriver.js';\nimport { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery.js';\nimport { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference.js';\nimport { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource.js';\n\n/*** Read safe public outputs exposed by Infra-owned Kubernetes resources. */\nexport async function getKubernetesOutputsAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n): Promise<InfraResult<readonly InfraOutput[]>> {\n try {\n const resources = await options.api.listOwnedAsync(getKubernetesOwnershipQuery(request));\n const outputs: InfraOutput[] = [];\n for (const resource of resources) {\n const owner = readKubernetesOwnedResource(resource, request);\n if (owner === undefined) continue;\n const observation = await options.api.observeAsync(\n getKubernetesResourceReference(resource),\n request.context.signal,\n );\n for (const [name, value] of Object.entries(observation.publicOutputs ?? {}).sort(([a], [b]) =>\n a.localeCompare(b),\n )) {\n outputs.push({ owner: owner.identity, name, visibility: 'public', value });\n }\n }\n return { ok: true, value: outputs, diagnostics: [] };\n } catch {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'kubernetes-outputs-failed',\n message: 'Kubernetes public outputs could not be read.',\n },\n ],\n };\n }\n}\n"]}
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraResourceStatus, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
2
|
+
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';
|
|
3
3
|
/*** Read provider-neutral status for every safely identified Infra-owned resource. */
|
|
4
4
|
export declare function getKubernetesStatusAsync(options: KubernetesDriverOptions, request: KubernetesDriverRequest): Promise<InfraResult<readonly InfraResourceStatus[]>>;
|
|
5
5
|
//# sourceMappingURL=getKubernetesStatusAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getKubernetesStatusAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEnF,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"getKubernetesStatusAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEnF,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAK/C,sFAAsF;AACtF,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,WAAW,CAAC,SAAS,mBAAmB,EAAE,CAAC,CAAC,CA8BtD"}
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery';
|
|
2
|
-
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';
|
|
3
|
-
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource';
|
|
1
|
+
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery.js';
|
|
2
|
+
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference.js';
|
|
3
|
+
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource.js';
|
|
4
4
|
/*** Read provider-neutral status for every safely identified Infra-owned resource. */
|
|
5
5
|
export async function getKubernetesStatusAsync(options, request) {
|
|
6
6
|
try {
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getKubernetesStatusAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,2BAA2B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getKubernetesStatusAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,sFAAsF;AACtF,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,OAAgC,EAChC,OAAgC;IAEhC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC,CAAC;QACzF,MAAM,QAAQ,GAA0B,EAAE,CAAC;QAC3C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,MAAM,KAAK,GAAG,2BAA2B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7D,IAAI,KAAK,KAAK,SAAS;gBAAE,SAAS;YAClC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAChD,8BAA8B,CAAC,QAAQ,CAAC,EACxC,OAAO,CAAC,OAAO,CAAC,MAAM,CACvB,CAAC;YACF,QAAQ,CAAC,IAAI,CAAC;gBACZ,KAAK,EAAE,KAAK,CAAC,QAAQ;gBACrB,KAAK,EAAE,WAAW,CAAC,KAAK;gBACxB,GAAG,CAAC,WAAW,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC;aAC5E,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,EAAE,EAAE,KAAK;YACT,WAAW,EAAE;gBACX;oBACE,QAAQ,EAAE,OAAO;oBACjB,IAAI,EAAE,0BAA0B;oBAChC,OAAO,EAAE,+CAA+C;iBACzD;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { InfraResourceStatus, InfraResult } from '@ankhorage/contracts/infra';\n\nimport type {\n KubernetesDriverOptions,\n KubernetesDriverRequest,\n} from '../../../../types/kubernetesDriver.js';\nimport { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery.js';\nimport { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference.js';\nimport { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource.js';\n\n/*** Read provider-neutral status for every safely identified Infra-owned resource. */\nexport async function getKubernetesStatusAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n): Promise<InfraResult<readonly InfraResourceStatus[]>> {\n try {\n const resources = await options.api.listOwnedAsync(getKubernetesOwnershipQuery(request));\n const statuses: InfraResourceStatus[] = [];\n for (const resource of resources) {\n const owner = readKubernetesOwnedResource(resource, request);\n if (owner === undefined) continue;\n const observation = await options.api.observeAsync(\n getKubernetesResourceReference(resource),\n request.context.signal,\n );\n statuses.push({\n owner: owner.identity,\n state: observation.state,\n ...(observation.detail === undefined ? {} : { detail: observation.detail }),\n });\n }\n return { ok: true, value: statuses, diagnostics: [] };\n } catch {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'kubernetes-status-failed',\n message: 'Kubernetes resource status could not be read.',\n },\n ],\n };\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
3
|
-
import type { KubernetesDesiredResource, KubernetesProjection } from '../../../../types/kubernetesResources';
|
|
2
|
+
import type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';
|
|
3
|
+
import type { KubernetesDesiredResource, KubernetesProjection } from '../../../../types/kubernetesResources.js';
|
|
4
4
|
/*** Resolve referenced secrets into ephemeral Kubernetes apply resources. */
|
|
5
5
|
export declare function materializeKubernetesSecretsAsync(request: KubernetesDriverRequest, projection: KubernetesProjection): Promise<InfraResult<readonly KubernetesDesiredResource[]>>;
|
|
6
6
|
//# sourceMappingURL=materializeKubernetesSecretsAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materializeKubernetesSecretsAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"materializeKubernetesSecretsAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EAErB,MAAM,0CAA0C,CAAC;AAGlD,6EAA6E;AAC7E,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,uBAAuB,EAChC,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,WAAW,CAAC,SAAS,yBAAyB,EAAE,CAAC,CAAC,CA6B5D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getKubernetesResourceKey } from '../../utils/getKubernetesResourceKey';
|
|
1
|
+
import { getKubernetesResourceKey } from '../../utils/getKubernetesResourceKey.js';
|
|
2
2
|
/*** Resolve referenced secrets into ephemeral Kubernetes apply resources. */
|
|
3
3
|
export async function materializeKubernetesSecretsAsync(request, projection) {
|
|
4
4
|
const values = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materializeKubernetesSecretsAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,wBAAwB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"materializeKubernetesSecretsAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAEnF,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,OAAgC,EAChC,UAAgC;IAEhC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkC,CAAC;IACzD,MAAM,WAAW,GAAsB,EAAE,CAAC;IAE1C,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,cAAc,EAAE,CAAC;QAChD,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3E,IAAI,CAAC,QAAQ,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C,CAAC;YAC3B,SAAS;QACX,CAAC;QACD,MAAM,QAAQ,GACZ,OAAO,CAAC,SAAS,CAAC,MAAM,KAAK,cAAc;YACzC,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC;YAC/D,CAAC,CAAC,MAAM,2BAA2B,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACpE,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,OAAO,QAAQ,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AAC/D,CAAC;AAED,KAAK,UAAU,2BAA2B,CACxC,OAAgC,EAChC,SAGC;IAED,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC3E,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC;IAClC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC5C,OAAO,KAAK,KAAK,SAAS;QACxB,CAAC,CAAC;YACE,EAAE,EAAE,KAAK;YACT,WAAW,EAAE;gBACX;oBACE,QAAQ,EAAE,OAAO;oBACjB,IAAI,EAAE,mCAAmC;oBACzC,OAAO,EAAE,uDAAuD;iBACjE;aACF;SACF;QACH,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["import type { InfraDiagnostic, InfraResult } from '@ankhorage/contracts/infra';\n\nimport type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';\nimport type {\n KubernetesDesiredResource,\n KubernetesProjection,\n KubernetesSecretValueSegment,\n} from '../../../../types/kubernetesResources.js';\nimport { getKubernetesResourceKey } from '../../utils/getKubernetesResourceKey.js';\n\n/*** Resolve referenced secrets into ephemeral Kubernetes apply resources. */\nexport async function materializeKubernetesSecretsAsync(\n request: KubernetesDriverRequest,\n projection: KubernetesProjection,\n): Promise<InfraResult<readonly KubernetesDesiredResource[]>> {\n const values = new Map<string, Record<string, string>>();\n const diagnostics: InfraDiagnostic[] = [];\n\n for (const binding of projection.secretBindings) {\n const resolved = await materializeSegmentsAsync(request, binding.segments);\n if (!resolved.ok) {\n diagnostics.push(...resolved.diagnostics);\n continue;\n }\n const resourceValues = values.get(getKubernetesResourceKey(binding.resource)) ?? {};\n resourceValues[binding.key] = resolved.value;\n values.set(getKubernetesResourceKey(binding.resource), resourceValues);\n }\n\n if (diagnostics.length > 0) return { ok: false, diagnostics };\n\n return {\n ok: true,\n value: projection.resources.map((desired) => {\n const secretValues = values.get(desired.owner.externalId ?? '');\n if (secretValues === undefined) return desired;\n return {\n ...desired,\n resource: { ...desired.resource, stringData: secretValues },\n };\n }),\n diagnostics: [],\n };\n}\n\n/*** Materialize and concatenate one ordered secret-backed value. */\nasync function materializeSegmentsAsync(\n request: KubernetesDriverRequest,\n segments: KubernetesProjection['secretBindings'][number]['segments'],\n): Promise<InfraResult<string>> {\n const values: string[] = [];\n for (const segment of segments) {\n if (segment.kind === 'literal') {\n values.push(segment.value);\n continue;\n }\n const resolved =\n segment.reference.source === 'secret-store'\n ? await request.context.secrets.resolveAsync(segment.reference)\n : await resolveCredentialValueAsync(request, segment.reference);\n if (!resolved.ok) return resolved;\n values.push(resolved.value);\n }\n return { ok: true, value: values.join(''), diagnostics: [] };\n}\n\nasync function resolveCredentialValueAsync(\n request: KubernetesDriverRequest,\n reference: Extract<\n Extract<KubernetesSecretValueSegment, { readonly kind: 'reference' }>['reference'],\n { source: 'control-plane' }\n >,\n): Promise<InfraResult<string>> {\n const resolved = await request.context.credentials.resolveAsync(reference);\n if (!resolved.ok) return resolved;\n const value = resolved.value[reference.key];\n return value === undefined\n ? {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'kubernetes-credential-key-missing',\n message: 'A required control-plane credential field is missing.',\n },\n ],\n }\n : { ok: true, value, diagnostics: [] };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraPlanAction, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
2
|
+
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';
|
|
3
3
|
/*** Produce a side-effect-free Kubernetes reconciliation plan. */
|
|
4
4
|
export declare function planKubernetesResourcesAsync(options: KubernetesDriverOptions, request: KubernetesDriverRequest): Promise<InfraResult<readonly InfraPlanAction[]>>;
|
|
5
5
|
//# sourceMappingURL=planKubernetesResourcesAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planKubernetesResourcesAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"planKubernetesResourcesAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAG/C,kEAAkE;AAClE,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,WAAW,CAAC,SAAS,eAAe,EAAE,CAAC,CAAC,CAKlD"}
|
package/dist/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { prepareKubernetesChangesAsync } from './prepareKubernetesChangesAsync';
|
|
1
|
+
import { prepareKubernetesChangesAsync } from './prepareKubernetesChangesAsync.js';
|
|
2
2
|
/*** Produce a side-effect-free Kubernetes reconciliation plan. */
|
|
3
3
|
export async function planKubernetesResourcesAsync(options, request) {
|
|
4
4
|
const prepared = await prepareKubernetesChangesAsync(options, request);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planKubernetesResourcesAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,6BAA6B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"planKubernetesResourcesAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,kEAAkE;AAClE,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,OAAgC,EAChC,OAAgC;IAEhC,MAAM,QAAQ,GAAG,MAAM,6BAA6B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvE,OAAO,QAAQ,CAAC,EAAE;QAChB,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;QAC1F,CAAC,CAAC,QAAQ,CAAC;AACf,CAAC","sourcesContent":["import type { InfraPlanAction, InfraResult } from '@ankhorage/contracts/infra';\n\nimport type {\n KubernetesDriverOptions,\n KubernetesDriverRequest,\n} from '../../../../types/kubernetesDriver.js';\nimport { prepareKubernetesChangesAsync } from './prepareKubernetesChangesAsync.js';\n\n/*** Produce a side-effect-free Kubernetes reconciliation plan. */\nexport async function planKubernetesResourcesAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n): Promise<InfraResult<readonly InfraPlanAction[]>> {\n const prepared = await prepareKubernetesChangesAsync(options, request);\n return prepared.ok\n ? { ok: true, value: prepared.value.changes.map(({ action }) => action), diagnostics: [] }\n : prepared;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
3
|
-
import type { KubernetesPreparedChanges } from '../../../../types/kubernetesResources';
|
|
2
|
+
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';
|
|
3
|
+
import type { KubernetesPreparedChanges } from '../../../../types/kubernetesResources.js';
|
|
4
4
|
/*** Prepare deterministic create, update, no-op, retain and stale-delete changes. */
|
|
5
5
|
export declare function prepareKubernetesChangesAsync(options: KubernetesDriverOptions, request: KubernetesDriverRequest): Promise<InfraResult<KubernetesPreparedChanges>>;
|
|
6
6
|
//# sourceMappingURL=prepareKubernetesChangesAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareKubernetesChangesAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"prepareKubernetesChangesAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAGV,yBAAyB,EAE1B,MAAM,0CAA0C,CAAC;AAUlD,qFAAqF;AACrF,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC,CAwBjD"}
|
package/dist/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { areKubernetesResourcesEquivalent } from '../../utils/areKubernetesResourcesEquivalent';
|
|
2
|
-
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery';
|
|
3
|
-
import { getKubernetesResourceKey } from '../../utils/getKubernetesResourceKey';
|
|
4
|
-
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';
|
|
5
|
-
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource';
|
|
6
|
-
import { sortKubernetesResourcesForRemoval } from '../../utils/sortKubernetesResourcesForRemoval';
|
|
7
|
-
import { materializeKubernetesSecretsAsync } from './materializeKubernetesSecretsAsync';
|
|
8
|
-
import { projectKubernetesResourcesAsync } from './projectKubernetesResourcesAsync';
|
|
1
|
+
import { areKubernetesResourcesEquivalent } from '../../utils/areKubernetesResourcesEquivalent.js';
|
|
2
|
+
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery.js';
|
|
3
|
+
import { getKubernetesResourceKey } from '../../utils/getKubernetesResourceKey.js';
|
|
4
|
+
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference.js';
|
|
5
|
+
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource.js';
|
|
6
|
+
import { sortKubernetesResourcesForRemoval } from '../../utils/sortKubernetesResourcesForRemoval.js';
|
|
7
|
+
import { materializeKubernetesSecretsAsync } from './materializeKubernetesSecretsAsync.js';
|
|
8
|
+
import { projectKubernetesResourcesAsync } from './projectKubernetesResourcesAsync.js';
|
|
9
9
|
/*** Prepare deterministic create, update, no-op, retain and stale-delete changes. */
|
|
10
10
|
export async function prepareKubernetesChangesAsync(options, request) {
|
|
11
11
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareKubernetesChangesAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gCAAgC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"prepareKubernetesChangesAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAC;AACnG,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,iCAAiC,EAAE,MAAM,kDAAkD,CAAC;AACrG,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAEvF,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,OAAgC,EAChC,OAAgC;IAEhC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,+BAA+B,CAAC,OAAO,CAAC,CAAC;QAClE,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AAC;IAC/B,CAAC,CAAC,CAAC;IACH,OAAO,iCAAiC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5E,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC7F,MAAM,EAAE,QAAQ;KACjB,CAAC,CAAC,CAAC;AACN,CAAC;AAED,0CAA0C;AAC1C,SAAS,YAAY,CACnB,KAA+B,EAC/B,SAAuC,EACvC,SAAuC;IAEvC,OAAO;QACL,KAAK;QACL,SAAS;QACT,MAAM,EAAE,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,MAAM;QAC9D,MAAM,EAAE,uBAAuB,KAAK,CAAC,UAAU,KAAK,SAAS,GAAG;QAChE,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import type { InfraPlanAction, InfraResult } from '@ankhorage/contracts/infra';\n\nimport type {\n KubernetesDriverOptions,\n KubernetesDriverRequest,\n} from '../../../../types/kubernetesDriver.js';\nimport type {\n KubernetesDesiredResource,\n KubernetesPreparedChange,\n KubernetesPreparedChanges,\n KubernetesResource,\n} from '../../../../types/kubernetesResources.js';\nimport { areKubernetesResourcesEquivalent } from '../../utils/areKubernetesResourcesEquivalent.js';\nimport { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery.js';\nimport { getKubernetesResourceKey } from '../../utils/getKubernetesResourceKey.js';\nimport { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference.js';\nimport { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource.js';\nimport { sortKubernetesResourcesForRemoval } from '../../utils/sortKubernetesResourcesForRemoval.js';\nimport { materializeKubernetesSecretsAsync } from './materializeKubernetesSecretsAsync.js';\nimport { projectKubernetesResourcesAsync } from './projectKubernetesResourcesAsync.js';\n\n/*** Prepare deterministic create, update, no-op, retain and stale-delete changes. */\nexport async function prepareKubernetesChangesAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n): Promise<InfraResult<KubernetesPreparedChanges>> {\n try {\n const projection = await projectKubernetesResourcesAsync(request);\n if (!projection.ok) return projection;\n const materialized = await materializeKubernetesSecretsAsync(request, projection.value);\n if (!materialized.ok) return materialized;\n const observed = await options.api.listOwnedAsync(getKubernetesOwnershipQuery(request));\n const desiredChanges = createDesiredChanges(materialized.value, observed);\n const desiredKeys = new Set(materialized.value.map(({ owner }) => owner.externalId ?? ''));\n const staleChanges = createStaleChanges(request, observed, desiredKeys);\n const changes = [...desiredChanges, ...staleChanges];\n return { ok: true, value: { changes, projection: projection.value }, diagnostics: [] };\n } catch {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'kubernetes-plan-failed',\n message: 'Kubernetes desired and observed resources could not be compared safely.',\n },\n ],\n };\n }\n}\n\n/*** Compare desired resources against the observed resource map. */\nfunction createDesiredChanges(\n desiredResources: readonly KubernetesDesiredResource[],\n observed: readonly KubernetesResource[],\n): readonly KubernetesPreparedChange[] {\n const actual = new Map(\n observed.map((resource) => [\n getKubernetesResourceKey(getKubernetesResourceReference(resource)),\n resource,\n ]),\n );\n return desiredResources.map((desired) => {\n const current = actual.get(desired.owner.externalId ?? '');\n const operation =\n current === undefined\n ? 'create'\n : areKubernetesResourcesEquivalent(desired.resource, current)\n ? 'noop'\n : 'update';\n return {\n action: createAction(desired.owner.identity, desired.owner.dependsOn, operation),\n desired,\n ...(current === undefined ? {} : { actual: current }),\n };\n });\n}\n\n/*** Identify obsolete owned resources without admitting malformed ownership metadata. */\nfunction createStaleChanges(\n request: KubernetesDriverRequest,\n observed: readonly KubernetesResource[],\n desiredKeys: ReadonlySet<string>,\n): readonly KubernetesPreparedChange[] {\n const stale = observed.flatMap((resource) => {\n const key = getKubernetesResourceKey(getKubernetesResourceReference(resource));\n if (desiredKeys.has(key)) return [];\n const owner = readKubernetesOwnedResource(resource, request);\n if (owner === undefined) return [];\n return [{ resource, owner }];\n });\n return sortKubernetesResourcesForRemoval(stale).map(({ resource, owner }) => ({\n action: createAction(owner.identity, owner.dependsOn, owner.persistent ? 'retain' : 'delete'),\n actual: resource,\n }));\n}\n\n/*** Create one non-secret plan action. */\nfunction createAction(\n owner: InfraPlanAction['owner'],\n dependsOn: InfraPlanAction['dependsOn'],\n operation: InfraPlanAction['operation'],\n): InfraPlanAction {\n return {\n owner,\n operation,\n impact: operation === 'delete' ? 'interrupts-service' : 'none',\n detail: `Kubernetes resource ${owner.resourceId}: ${operation}.`,\n dependsOn,\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
3
|
-
import type { KubernetesProjection } from '../../../../types/kubernetesResources';
|
|
2
|
+
import type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';
|
|
3
|
+
import type { KubernetesProjection } from '../../../../types/kubernetesResources.js';
|
|
4
4
|
/***
|
|
5
5
|
* Project portable workload desired state into deterministic standard Kubernetes resources.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectKubernetesResourcesAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"projectKubernetesResourcesAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,0CAA0C,CAAC;AAOlD;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CA8B5C"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createKubernetesDesiredResource } from '../../utils/createKubernetesDesiredResource';
|
|
2
|
-
import { createKubernetesIdentity } from '../../utils/createKubernetesIdentity';
|
|
3
|
-
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery';
|
|
4
|
-
import { projectKubernetesWorkload } from './projectKubernetesWorkload';
|
|
5
|
-
import { validateKubernetesWorkloads } from './validateKubernetesWorkloads';
|
|
1
|
+
import { createKubernetesDesiredResource } from '../../utils/createKubernetesDesiredResource.js';
|
|
2
|
+
import { createKubernetesIdentity } from '../../utils/createKubernetesIdentity.js';
|
|
3
|
+
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery.js';
|
|
4
|
+
import { projectKubernetesWorkload } from './projectKubernetesWorkload.js';
|
|
5
|
+
import { validateKubernetesWorkloads } from './validateKubernetesWorkloads.js';
|
|
6
6
|
/***
|
|
7
7
|
* Project portable workload desired state into deterministic standard Kubernetes resources.
|
|
8
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectKubernetesResourcesAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,+BAA+B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"projectKubernetesResourcesAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAQA,OAAO,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AE;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACrD,SAAS,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC7C,cAAc,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,EAAE,EAAE,IAAI;QACR,KAAK,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE;QACpC,WAAW,EAAE,EAAE;KAChB,CAAC,CAAC;AACL,CAAC;AAED,yEAAyE;AACzE,SAAS,eAAe,CACtB,OAAgC,EAChC,SAAiB;IAEjB,OAAO,+BAA+B,CAAC,OAAO,EAAE;QAC9C,UAAU,EAAE,aAAa,SAAS,EAAE;QACpC,QAAQ,EAAE;YACR,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;SAC3D;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { InfraResult } from '@ankhorage/contracts/infra';\n\nimport type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';\nimport type {\n KubernetesDesiredResource,\n KubernetesProjection,\n KubernetesSecretBinding,\n} from '../../../../types/kubernetesResources.js';\nimport { createKubernetesDesiredResource } from '../../utils/createKubernetesDesiredResource.js';\nimport { createKubernetesIdentity } from '../../utils/createKubernetesIdentity.js';\nimport { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery.js';\nimport { projectKubernetesWorkload } from './projectKubernetesWorkload.js';\nimport { validateKubernetesWorkloads } from './validateKubernetesWorkloads.js';\n\n/***\n * Project portable workload desired state into deterministic standard Kubernetes resources.\n *\n * Resolved secret values are deliberately absent. The projection carries only references for\n * runtime materialization immediately before apply.\n *\n * @readme\n */\nexport function projectKubernetesResourcesAsync(\n request: KubernetesDriverRequest,\n): Promise<InfraResult<KubernetesProjection>> {\n const validation = validateKubernetesWorkloads(request.workloads);\n if (validation.length > 0) return Promise.resolve({ ok: false, diagnostics: validation });\n\n const { namespace } = getKubernetesOwnershipQuery(request);\n const namespaceResource = createNamespace(request, namespace);\n const workloadOwners = new Map(\n request.workloads.map((workload) => [\n workload.id,\n createKubernetesIdentity(request, `workload:${workload.id}`),\n ]),\n );\n const resources: KubernetesDesiredResource[] = [namespaceResource];\n const secretBindings: KubernetesSecretBinding[] = [];\n for (const workload of request.workloads) {\n const projected = projectKubernetesWorkload(request, {\n namespace,\n namespaceOwner: namespaceResource.owner.identity,\n workloadOwners,\n workload,\n });\n if (!projected.ok) return Promise.resolve(projected);\n resources.push(...projected.value.resources);\n secretBindings.push(...projected.value.secretBindings);\n }\n return Promise.resolve({\n ok: true,\n value: { resources, secretBindings },\n diagnostics: [],\n });\n}\n\n/*** Create the environment namespace before all namespaced resources. */\nfunction createNamespace(\n request: KubernetesDriverRequest,\n namespace: string,\n): KubernetesDesiredResource {\n return createKubernetesDesiredResource(request, {\n resourceId: `namespace:${namespace}`,\n resource: {\n apiVersion: 'v1',\n kind: 'Namespace',\n metadata: { name: namespace, labels: {}, annotations: {} },\n },\n });\n}\n"]}
|
package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InfraResourceIdentity, InfraResult, InfraWorkloadSpec } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
3
|
-
import type { KubernetesWorkloadProjection } from '../../../../types/kubernetesResources';
|
|
2
|
+
import type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';
|
|
3
|
+
import type { KubernetesWorkloadProjection } from '../../../../types/kubernetesResources.js';
|
|
4
4
|
/*** Project one workload while retaining dependency-first resource ordering. */
|
|
5
5
|
export declare function projectKubernetesWorkload(request: KubernetesDriverRequest, input: ProjectKubernetesWorkloadInput): InfraResult<KubernetesWorkloadProjection>;
|
|
6
6
|
export interface ProjectKubernetesWorkloadInput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectKubernetesWorkload.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"projectKubernetesWorkload.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AAO7F,gFAAgF;AAChF,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,8BAA8B,GACpC,WAAW,CAAC,4BAA4B,CAAC,CAsC3C;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;IAC/C,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACpE,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;CACtC"}
|
package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { toKubernetesName } from '../../utils/toKubernetesName';
|
|
2
|
-
import { createKubernetesController } from './createKubernetesController';
|
|
3
|
-
import { createKubernetesExposure } from './createKubernetesExposure';
|
|
4
|
-
import { createKubernetesPrerequisites } from './createKubernetesPrerequisites';
|
|
5
|
-
import { resolveKubernetesWorkloadValues } from './resolveKubernetesWorkloadValues';
|
|
1
|
+
import { toKubernetesName } from '../../utils/toKubernetesName.js';
|
|
2
|
+
import { createKubernetesController } from './createKubernetesController.js';
|
|
3
|
+
import { createKubernetesExposure } from './createKubernetesExposure.js';
|
|
4
|
+
import { createKubernetesPrerequisites } from './createKubernetesPrerequisites.js';
|
|
5
|
+
import { resolveKubernetesWorkloadValues } from './resolveKubernetesWorkloadValues.js';
|
|
6
6
|
/*** Project one workload while retaining dependency-first resource ordering. */
|
|
7
7
|
export function projectKubernetesWorkload(request, input) {
|
|
8
8
|
const workloadName = toKubernetesName(input.workload.id);
|
package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectKubernetesWorkload.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"projectKubernetesWorkload.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAEvF,gFAAgF;AAChF,MAAM,UAAU,yBAAyB,CACvC,OAAgC,EAChC,KAAqC;IAErC,MAAM,YAAY,G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UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ;KACtC,CAAC,CAAC;IACH,OAAO;QACL,EAAE,EAAE,IAAI;QACR,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,GAAG,aAAa,CAAC,SAAS,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;YAChE,cAAc,EAAE,aAAa,CAAC,cAAc;SAC7C;QACD,WAAW,EAAE,EAAE;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InfraResourceIdentity,\n InfraResult,\n InfraWorkloadSpec,\n} from '@ankhorage/contracts/infra';\n\nimport type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';\nimport type { KubernetesWorkloadProjection } from '../../../../types/kubernetesResources.js';\nimport { toKubernetesName } from '../../utils/toKubernetesName.js';\nimport { createKubernetesController } from './createKubernetesController.js';\nimport { createKubernetesExposure } from './createKubernetesExposure.js';\nimport { createKubernetesPrerequisites } from './createKubernetesPrerequisites.js';\nimport { resolveKubernetesWorkloadValues } from './resolveKubernetesWorkloadValues.js';\n\n/*** Project one workload while retaining dependency-first resource ordering. */\nexport function projectKubernetesWorkload(\n request: KubernetesDriverRequest,\n input: ProjectKubernetesWorkloadInput,\n): InfraResult<KubernetesWorkloadProjection> {\n const workloadName = toKubernetesName(input.workload.id);\n const values = resolveKubernetesWorkloadValues(request.availableOutputs ?? [], input.workload);\n if (!values.ok) return values;\n const prerequisites = createKubernetesPrerequisites(request, {\n namespace: input.namespace,\n namespaceOwner: input.namespaceOwner,\n workloadName,\n workload: input.workload,\n values: values.value,\n });\n const declaredDependencies = Object.keys(input.workload.dependsOn ?? {})\n .sort()\n .flatMap((id) => {\n const owner = input.workloadOwners.get(id);\n return owner === undefined ? [] : [owner];\n });\n const controller = createKubernetesController(request, {\n namespace: input.namespace,\n workloadName,\n workload: input.workload,\n values: values.value,\n dependsOn: [...prerequisites.owners, ...declaredDependencies],\n });\n const exposure = createKubernetesExposure(request, {\n namespace: input.namespace,\n workloadName,\n workload: input.workload,\n controller: controller.owner.identity,\n });\n return {\n ok: true,\n value: {\n resources: [...prerequisites.resources, controller, ...exposure],\n secretBindings: prerequisites.secretBindings,\n },\n diagnostics: [],\n };\n}\n\nexport interface ProjectKubernetesWorkloadInput {\n readonly namespace: string;\n readonly namespaceOwner: InfraResourceIdentity;\n readonly workloadOwners: ReadonlyMap<string, InfraResourceIdentity>;\n readonly workload: InfraWorkloadSpec;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraReconcileResult, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
2
|
+
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';
|
|
3
3
|
/*** Apply desired changes dependency-first and prune only obsolete, non-persistent Infra resources. */
|
|
4
4
|
export declare function reconcileKubernetesResourcesAsync(options: KubernetesDriverOptions, request: KubernetesDriverRequest): Promise<InfraResult<InfraReconcileResult>>;
|
|
5
5
|
//# sourceMappingURL=reconcileKubernetesResourcesAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcileKubernetesResourcesAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,oBAAoB,EACpB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"reconcileKubernetesResourcesAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,oBAAoB,EACpB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAe/C,uGAAuG;AACvG,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAuC5C"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { KUBERNETES_DEFAULT_READINESS_TIMEOUT_SECONDS, KUBERNETES_READINESS_KINDS, } from '../../constants';
|
|
2
|
-
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';
|
|
3
|
-
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource';
|
|
4
|
-
import { getKubernetesOutputsAsync } from './getKubernetesOutputsAsync';
|
|
5
|
-
import { prepareKubernetesChangesAsync } from './prepareKubernetesChangesAsync';
|
|
1
|
+
import { KUBERNETES_DEFAULT_READINESS_TIMEOUT_SECONDS, KUBERNETES_READINESS_KINDS, } from '../../constants.js';
|
|
2
|
+
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference.js';
|
|
3
|
+
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource.js';
|
|
4
|
+
import { getKubernetesOutputsAsync } from './getKubernetesOutputsAsync.js';
|
|
5
|
+
import { prepareKubernetesChangesAsync } from './prepareKubernetesChangesAsync.js';
|
|
6
6
|
/*** Apply desired changes dependency-first and prune only obsolete, non-persistent Infra resources. */
|
|
7
7
|
export async function reconcileKubernetesResourcesAsync(options, request) {
|
|
8
8
|
const prepared = await prepareKubernetesChangesAsync(options, request);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcileKubernetesResourcesAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,4CAA4C,EAC5C,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,8BAA8B,EAAE,MA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,sDAAsD;aAChE;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InfraDiagnostic,\n InfraOwnedResource,\n InfraReconcileResult,\n InfraResult,\n} from '@ankhorage/contracts/infra';\n\nimport type {\n KubernetesDriverOptions,\n KubernetesDriverRequest,\n} from '../../../../types/kubernetesDriver';\nimport type {\n KubernetesDesiredResource,\n KubernetesPreparedChange,\n KubernetesResourceObservation,\n} from '../../../../types/kubernetesResources';\nimport {\n KUBERNETES_DEFAULT_READINESS_TIMEOUT_SECONDS,\n KUBERNETES_READINESS_KINDS,\n} from '../../constants';\nimport { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';\nimport { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource';\nimport { getKubernetesOutputsAsync } from './getKubernetesOutputsAsync';\nimport { prepareKubernetesChangesAsync } from './prepareKubernetesChangesAsync';\n\n/*** Apply desired changes dependency-first and prune only obsolete, non-persistent Infra resources. */\nexport async function reconcileKubernetesResourcesAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n): Promise<InfraResult<InfraReconcileResult>> {\n const prepared = await prepareKubernetesChangesAsync(options, request);\n if (!prepared.ok) return prepared;\n\n const desiredByResourceId = new Map(\n prepared.value.projection.resources.map((desired) => [\n desired.owner.identity.resourceId,\n desired,\n ]),\n );\n const timeoutSeconds =\n options.defaultReadinessTimeoutSeconds ?? KUBERNETES_DEFAULT_READINESS_TIMEOUT_SECONDS;\n const deadline = Date.now() + timeoutSeconds * 1_000;\n\n try {\n const reconciled = await applyKubernetesChangesAsync(\n options,\n request,\n prepared.value.changes,\n desiredByResourceId,\n deadline,\n );\n if (!reconciled.ok) return reconciled;\n const outputs = await getKubernetesOutputsAsync(options, request);\n if (!outputs.ok) return outputs;\n return {\n ok: true,\n value: {\n resources: [\n ...prepared.value.projection.resources.map(({ owner }) => owner),\n ...reconciled.value,\n ],\n outputs: outputs.value,\n },\n diagnostics: [],\n };\n } catch {\n return createReconcileFailure();\n }\n}\n\n/*** Apply prepared changes while enforcing readiness-relevant dependency gates. */\nasync function applyKubernetesChangesAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n changes: readonly KubernetesPreparedChange[],\n desiredByResourceId: ReadonlyMap<string, KubernetesDesiredResource>,\n deadline: number,\n): Promise<InfraResult<readonly InfraOwnedResource[]>> {\n const retained: InfraOwnedResource[] = [];\n for (const change of changes) {\n if (\n (change.action.operation === 'create' || change.action.operation === 'update') &&\n change.desired !== undefined\n ) {\n const dependencyFailure = await waitForDependenciesAsync(\n options,\n request,\n change.desired,\n desiredByResourceId,\n deadline,\n );\n if (dependencyFailure !== undefined) {\n return { ok: false, diagnostics: [dependencyFailure] };\n }\n await options.api.applyAsync(change.desired.resource, request.context.signal);\n }\n if (change.action.operation === 'delete' && change.actual !== undefined) {\n await options.api.deleteAsync(\n getKubernetesResourceReference(change.actual),\n request.context.signal,\n );\n }\n if (change.action.operation === 'retain' && change.actual !== undefined) {\n const owner = readKubernetesOwnedResource(change.actual, request);\n if (owner !== undefined) retained.push(owner);\n }\n }\n return { ok: true, value: retained, diagnostics: [] };\n}\n\n/*** Wait for readiness-relevant dependencies before applying one desired Kubernetes resource. */\nasync function waitForDependenciesAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n desired: KubernetesDesiredResource,\n desiredByResourceId: ReadonlyMap<string, KubernetesDesiredResource>,\n deadline: number,\n): Promise<InfraDiagnostic | undefined> {\n for (const dependencyOwner of desired.owner.dependsOn) {\n const dependency = desiredByResourceId.get(dependencyOwner.resourceId);\n if (dependency === undefined || !KUBERNETES_READINESS_KINDS.has(dependency.resource.kind)) {\n continue;\n }\n const observation = await waitForDependencyAsync(options, request, dependency, deadline);\n if (observation.state !== 'ready') {\n return createDependencyReadinessDiagnostic(dependency, observation);\n }\n }\n return undefined;\n}\n\n/*** Wait for one dependency within the reconciliation pass shared readiness deadline. */\nfunction waitForDependencyAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n dependency: KubernetesDesiredResource,\n deadline: number,\n): Promise<KubernetesResourceObservation> {\n const remainingSeconds = Math.max(0, Math.ceil((deadline - Date.now()) / 1_000));\n if (remainingSeconds === 0) {\n return Promise.resolve({\n state: 'degraded',\n detail: 'The shared Kubernetes readiness deadline expired.',\n });\n }\n return options.api.waitUntilReadyAsync(getKubernetesResourceReference(dependency.resource), {\n timeoutSeconds: remainingSeconds,\n ...(request.context.signal === undefined ? {} : { signal: request.context.signal }),\n });\n}\n\n/*** Create an actionable diagnostic for a dependency that did not become ready. */\nfunction createDependencyReadinessDiagnostic(\n dependency: KubernetesDesiredResource,\n observation: KubernetesResourceObservation,\n): InfraDiagnostic {\n const detail = observation.detail === undefined ? '' : ` ${observation.detail}`;\n return {\n severity: 'error',\n code: 'kubernetes-dependency-readiness-failed',\n message: `Kubernetes dependency ${dependency.owner.identity.resourceId} is ${observation.state}.${detail}`,\n owner: dependency.owner.identity,\n };\n}\n\n/*** Create the generic failure returned when reconciliation throws unexpectedly. */\nfunction createReconcileFailure(): InfraResult<InfraReconcileResult> {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'kubernetes-reconcile-failed',\n message: 'Kubernetes resources could not be reconciled safely.',\n },\n ],\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reconcileKubernetesResourcesAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,4CAA4C,EAC5C,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,uGAAuG;AACvG,MAAM,CAAC,K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AAC,OAAO,CAAC;YACrB,KAAK,EAAE,UAAU;YACjB,MAAM,EAAE,mDAAmD;SAC5D,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,8BAA8B,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC1F,cAAc,EAAE,gBAAgB;QAChC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;KACpF,CAAC,CAAC;AACL,CAAC;AAED,mFAAmF;AACnF,SAAS,mCAAmC,CAC1C,UAAqC,EACrC,WAA0C;IAE1C,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;IAChF,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,wCAAwC;QAC9C,OAAO,EAAE,yBAAyB,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,OAAO,WAAW,CAAC,KAAK,IAAI,MAAM,EAAE;QAC1G,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ;KACjC,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,SAAS,sBAAsB;IAC7B,OAAO;QACL,EAAE,EAAE,KAAK;QACT,WAAW,EAAE;YACX;gBACE,QAAQ,EAAE,OAAO;gBACjB,IAAI,EAAE,6BAA6B;gBACnC,OAAO,EAAE,sDAAsD;aAChE;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InfraDiagnostic,\n InfraOwnedResource,\n InfraReconcileResult,\n InfraResult,\n} from '@ankhorage/contracts/infra';\n\nimport type {\n KubernetesDriverOptions,\n KubernetesDriverRequest,\n} from '../../../../types/kubernetesDriver.js';\nimport type {\n KubernetesDesiredResource,\n KubernetesPreparedChange,\n KubernetesResourceObservation,\n} from '../../../../types/kubernetesResources.js';\nimport {\n KUBERNETES_DEFAULT_READINESS_TIMEOUT_SECONDS,\n KUBERNETES_READINESS_KINDS,\n} from '../../constants.js';\nimport { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference.js';\nimport { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource.js';\nimport { getKubernetesOutputsAsync } from './getKubernetesOutputsAsync.js';\nimport { prepareKubernetesChangesAsync } from './prepareKubernetesChangesAsync.js';\n\n/*** Apply desired changes dependency-first and prune only obsolete, non-persistent Infra resources. */\nexport async function reconcileKubernetesResourcesAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n): Promise<InfraResult<InfraReconcileResult>> {\n const prepared = await prepareKubernetesChangesAsync(options, request);\n if (!prepared.ok) return prepared;\n\n const desiredByResourceId = new Map(\n prepared.value.projection.resources.map((desired) => [\n desired.owner.identity.resourceId,\n desired,\n ]),\n );\n const timeoutSeconds =\n options.defaultReadinessTimeoutSeconds ?? KUBERNETES_DEFAULT_READINESS_TIMEOUT_SECONDS;\n const deadline = Date.now() + timeoutSeconds * 1_000;\n\n try {\n const reconciled = await applyKubernetesChangesAsync(\n options,\n request,\n prepared.value.changes,\n desiredByResourceId,\n deadline,\n );\n if (!reconciled.ok) return reconciled;\n const outputs = await getKubernetesOutputsAsync(options, request);\n if (!outputs.ok) return outputs;\n return {\n ok: true,\n value: {\n resources: [\n ...prepared.value.projection.resources.map(({ owner }) => owner),\n ...reconciled.value,\n ],\n outputs: outputs.value,\n },\n diagnostics: [],\n };\n } catch {\n return createReconcileFailure();\n }\n}\n\n/*** Apply prepared changes while enforcing readiness-relevant dependency gates. */\nasync function applyKubernetesChangesAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n changes: readonly KubernetesPreparedChange[],\n desiredByResourceId: ReadonlyMap<string, KubernetesDesiredResource>,\n deadline: number,\n): Promise<InfraResult<readonly InfraOwnedResource[]>> {\n const retained: InfraOwnedResource[] = [];\n for (const change of changes) {\n if (\n (change.action.operation === 'create' || change.action.operation === 'update') &&\n change.desired !== undefined\n ) {\n const dependencyFailure = await waitForDependenciesAsync(\n options,\n request,\n change.desired,\n desiredByResourceId,\n deadline,\n );\n if (dependencyFailure !== undefined) {\n return { ok: false, diagnostics: [dependencyFailure] };\n }\n await options.api.applyAsync(change.desired.resource, request.context.signal);\n }\n if (change.action.operation === 'delete' && change.actual !== undefined) {\n await options.api.deleteAsync(\n getKubernetesResourceReference(change.actual),\n request.context.signal,\n );\n }\n if (change.action.operation === 'retain' && change.actual !== undefined) {\n const owner = readKubernetesOwnedResource(change.actual, request);\n if (owner !== undefined) retained.push(owner);\n }\n }\n return { ok: true, value: retained, diagnostics: [] };\n}\n\n/*** Wait for readiness-relevant dependencies before applying one desired Kubernetes resource. */\nasync function waitForDependenciesAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n desired: KubernetesDesiredResource,\n desiredByResourceId: ReadonlyMap<string, KubernetesDesiredResource>,\n deadline: number,\n): Promise<InfraDiagnostic | undefined> {\n for (const dependencyOwner of desired.owner.dependsOn) {\n const dependency = desiredByResourceId.get(dependencyOwner.resourceId);\n if (dependency === undefined || !KUBERNETES_READINESS_KINDS.has(dependency.resource.kind)) {\n continue;\n }\n const observation = await waitForDependencyAsync(options, request, dependency, deadline);\n if (observation.state !== 'ready') {\n return createDependencyReadinessDiagnostic(dependency, observation);\n }\n }\n return undefined;\n}\n\n/*** Wait for one dependency within the reconciliation pass shared readiness deadline. */\nfunction waitForDependencyAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n dependency: KubernetesDesiredResource,\n deadline: number,\n): Promise<KubernetesResourceObservation> {\n const remainingSeconds = Math.max(0, Math.ceil((deadline - Date.now()) / 1_000));\n if (remainingSeconds === 0) {\n return Promise.resolve({\n state: 'degraded',\n detail: 'The shared Kubernetes readiness deadline expired.',\n });\n }\n return options.api.waitUntilReadyAsync(getKubernetesResourceReference(dependency.resource), {\n timeoutSeconds: remainingSeconds,\n ...(request.context.signal === undefined ? {} : { signal: request.context.signal }),\n });\n}\n\n/*** Create an actionable diagnostic for a dependency that did not become ready. */\nfunction createDependencyReadinessDiagnostic(\n dependency: KubernetesDesiredResource,\n observation: KubernetesResourceObservation,\n): InfraDiagnostic {\n const detail = observation.detail === undefined ? '' : ` ${observation.detail}`;\n return {\n severity: 'error',\n code: 'kubernetes-dependency-readiness-failed',\n message: `Kubernetes dependency ${dependency.owner.identity.resourceId} is ${observation.state}.${detail}`,\n owner: dependency.owner.identity,\n };\n}\n\n/*** Create the generic failure returned when reconciliation throws unexpectedly. */\nfunction createReconcileFailure(): InfraResult<InfraReconcileResult> {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'kubernetes-reconcile-failed',\n message: 'Kubernetes resources could not be reconciled safely.',\n },\n ],\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraDestroyRequest, InfraReconcileResult, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
2
|
+
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver.js';
|
|
3
3
|
/*** Remove owned resources in reverse dependency order while enforcing persistence authorization. */
|
|
4
4
|
export declare function removeKubernetesResourcesAsync(options: KubernetesDriverOptions, request: KubernetesDriverRequest, destroy: InfraDestroyRequest): Promise<InfraResult<InfraReconcileResult>>;
|
|
5
5
|
//# sourceMappingURL=removeKubernetesResourcesAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeKubernetesResourcesAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/removeKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAEnB,oBAAoB,EAEpB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"removeKubernetesResourcesAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/removeKubernetesResourcesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAEnB,oBAAoB,EAEpB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAM/C,qGAAqG;AACrG,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CA6B5C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery';
|
|
2
|
-
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';
|
|
3
|
-
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource';
|
|
4
|
-
import { sortKubernetesResourcesForRemoval } from '../../utils/sortKubernetesResourcesForRemoval';
|
|
1
|
+
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery.js';
|
|
2
|
+
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference.js';
|
|
3
|
+
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource.js';
|
|
4
|
+
import { sortKubernetesResourcesForRemoval } from '../../utils/sortKubernetesResourcesForRemoval.js';
|
|
5
5
|
/*** Remove owned resources in reverse dependency order while enforcing persistence authorization. */
|
|
6
6
|
export async function removeKubernetesResourcesAsync(options, request, destroy) {
|
|
7
7
|
if (!isConfirmed(request, destroy)) {
|