"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GithubRunnersDatasource = void 0;
const docker_1 = require("../../versioning/docker");
const datasource_1 = require("../datasource");
class GithubRunnersDatasource extends datasource_1.Datasource {
    static id = 'github-runners';
    /**
     * Only add stable runners to the datasource. See datasource readme for details.
     */
    static releases = {
        ubuntu: [{ version: '22.04' }, { version: '20.04' }, { version: '18.04' }],
        macos: [
            { version: '13' },
            { version: '13-xl' },
            { version: '12' },
            { version: '12-xl' },
            { version: '11' },
            { version: '10.15' },
        ],
        windows: [{ version: '2022' }, { version: '2019' }],
    };
    static isValidRunner(runnerName, runnerVersion) {
        const runnerReleases = GithubRunnersDatasource.releases[runnerName];
        if (!runnerReleases) {
            return false;
        }
        const versionExists = runnerReleases.some(({ version }) => version === runnerVersion);
        return runnerVersion === 'latest' || versionExists;
    }
    defaultVersioning = docker_1.id;
    constructor() {
        super(GithubRunnersDatasource.id);
    }
    getReleases({ packageName, }) {
        const releases = GithubRunnersDatasource.releases[packageName];
        const releaseResult = releases
            ? {
                releases,
                sourceUrl: 'https://github.com/actions/runner-images',
            }
            : null;
        return Promise.resolve(releaseResult);
    }
}
exports.GithubRunnersDatasource = GithubRunnersDatasource;
//# sourceMappingURL=index.js.map