// SPDX-License-Identifier: Apache-2.0
import yaml from 'yaml';
import fs from 'node:fs';
export class K8ClientManifests {
    k8sObjectApi;
    constructor(k8sObjectApi) {
        this.k8sObjectApi = k8sObjectApi;
    }
    /**
     * Apply a CRD manifest file (like `kubectl apply -f <file>`).
     * Uses server-side apply (Content-Type: application/apply-patch+yaml)
     * via KubernetesObjectApi.
     */
    async applyManifest(filePath) {
        const yamlText = fs.readFileSync(filePath, 'utf8');
        const documents = yaml
            .parseAllDocuments(yamlText)
            .map((document) => document.toJSON());
        for (const document of documents) {
            if (!document || !document.metadata) {
                continue;
            }
            await this.k8sObjectApi.create(document);
        }
    }
}
//# sourceMappingURL=k8-client-manifests.js.map