"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HelmReleaseExtractor = void 0;
const tslib_1 = require("tslib");
const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
const helm_1 = require("../../../../datasource/helm");
const base_1 = require("../../base");
const util_1 = require("../../util");
class HelmReleaseExtractor extends base_1.DependencyExtractor {
    getCheckList() {
        return [`"helm_release"`];
    }
    extract(hclMap) {
        const dependencies = [];
        const helmReleases = hclMap?.resource?.helm_release;
        if (is_1.default.nullOrUndefined(helmReleases)) {
            return [];
        }
        for (const helmReleaseName of Object.keys(helmReleases)) {
            for (const helmRelease of helmReleases[helmReleaseName]) {
                const dep = {
                    currentValue: helmRelease.version,
                    depType: 'helm_release',
                    depName: helmRelease.chart,
                    datasource: helm_1.HelmDatasource.id,
                };
                if (!is_1.default.nullOrUndefined(helmRelease.repository)) {
                    dep.registryUrls = [helmRelease.repository];
                }
                if (!helmRelease.chart) {
                    dep.skipReason = 'invalid-name';
                }
                else if ((0, util_1.checkIfStringIsPath)(helmRelease.chart)) {
                    dep.skipReason = 'local-chart';
                }
                dependencies.push(dep);
            }
        }
        return dependencies;
    }
}
exports.HelmReleaseExtractor = HelmReleaseExtractor;
//# sourceMappingURL=helm-release.js.map