"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const FS = tslib_1.__importStar(require("fs"));
const Path = tslib_1.__importStar(require("path"));
const node_shared_1 = require("../../../../bld/node-shared");
class Config extends node_shared_1.AbstractConfig {
    get name() {
        let { name = 'remote-workspace' } = this.raw;
        return name;
    }
    get host() {
        let { host = '0.0.0.0' } = this.raw;
        return host;
    }
    get port() {
        let { port = 8022 } = this.raw;
        return port;
    }
    get identity() {
        let { git: { identityFile }, } = this.raw;
        return FS.readFileSync(Path.join(this.dir, identityFile), 'utf8');
    }
    get users() {
        return this.raw.users;
    }
    get image() {
        let { image = 'makeflow/remote-workspace:latest' } = this.raw;
        return image;
    }
    get sharedVolumes() {
        let { volumes: { shared = [] } = {} } = this.raw;
        return shared;
    }
    get templates() {
        let { templates = {} } = this.raw;
        return templates;
    }
    get gitHostToServiceConfigMap() {
        let { git: { services = [] }, } = this.raw;
        if (!services.some(service => service.type === 'github')) {
            services.push({
                type: 'github',
            });
        }
        if (!services.some(service => service.type === 'gitlab' && service.host === 'gitlab.com')) {
            services.push({
                type: 'gitlab',
                host: 'gitlab.com',
            });
        }
        return new Map(services.map(config => [
            config.type === 'github' ? 'github.com' : config.host || 'gitlab.com',
            config,
        ]));
    }
}
exports.Config = Config;
//# sourceMappingURL=config.js.map