// SPDX-License-Identifier: Apache-2.0
import { container } from 'tsyringe-neo';
import { InjectTokens } from '../../../../../core/dependency-injection/inject-tokens.js';
export class K8ClientCrds {
    networkingApi;
    logger;
    constructor(networkingApi) {
        this.networkingApi = networkingApi;
        this.logger = container.resolve(InjectTokens.SoloLogger);
    }
    async ifExists(crdName) {
        try {
            const response = await this.networkingApi.readCustomResourceDefinition(crdName);
            this.logger.debug(`CRD ${crdName} exists, response:`, response);
            return true;
        }
        catch (error) {
            if (error.response && error.response.statusCode === 404) {
                this.logger.error(`CRD ${crdName} does not exist.`);
                return false;
            }
            else {
                this.logger.error('Error checking CRD:', error);
                throw error; // Re-throw unexpected errors
            }
        }
    }
}
//# sourceMappingURL=k8-client-crds.js.map