UNPKG

k8ts

Version:

Powerful framework for building Kubernetes manifests in TypeScript.

31 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveDataSourceRecord = resolveDataSourceRecord; const instruments_1 = require("@k8ts/instruments"); const what_are_you_1 = require("what-are-you"); async function resolveDataSourceRecord(resource, input) { const binaryData = []; const data = []; const entries = Object.entries(input ?? {}); for (const [k, v] of entries) { let current = v; if (current instanceof instruments_1.DataSource_Lazy) { current = await current.get(); } if ((0, what_are_you_1.isTypedArray)(current) || (0, what_are_you_1.isArrayBufferLike)(current)) { const encoded = Buffer.from(current).toString("base64"); binaryData.push([k, encoded]); } else if (typeof current === "string") { data.push([k, current]); } else { throw new Error(`Unsupported DataSource for ConfigMap ${resource} key "${k}"`); } } return { data: Object.fromEntries(data), binaryData: Object.fromEntries(binaryData) }; } //# sourceMappingURL=resolver.js.map