now respoecting registryrepo maps

This commit is contained in:
Philipp Kunz 2017-08-28 18:09:59 +02:00
parent 11ec419700
commit 1a465f336d
5 changed files with 51 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -4,4 +4,5 @@ export interface INpmciOptions {
dockerRegistryRepoMap: any; dockerRegistryRepoMap: any;
} }
export declare let kvStorage: KeyValueStore; export declare let kvStorage: KeyValueStore;
export declare let configObject: INpmciOptions;
export declare let getConfig: () => Promise<INpmciOptions>; export declare let getConfig: () => Promise<INpmciOptions>;

17
dist/npmci.config.js vendored
View File

@ -14,13 +14,14 @@ const npmci_env_1 = require("./npmci.env");
const npmextra_1 = require("npmextra"); const npmextra_1 = require("npmextra");
// instantiate a kvStorage for the current directory // instantiate a kvStorage for the current directory
exports.kvStorage = new npmextra_1.KeyValueStore('custom', `${npmci_env_1.repo.user}_${npmci_env_1.repo.repo}`); exports.kvStorage = new npmextra_1.KeyValueStore('custom', `${npmci_env_1.repo.user}_${npmci_env_1.repo.repo}`);
// handle config retrival
let npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
let defaultConfig = {
npmGlobalTools: [],
dockerRegistryRepoMap: {}
};
exports.configObject = npmciNpmextra.dataFor('npmci', defaultConfig);
exports.getConfig = () => __awaiter(this, void 0, void 0, function* () { exports.getConfig = () => __awaiter(this, void 0, void 0, function* () {
let npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd); return exports.configObject;
let defaultConfig = {
npmGlobalTools: [],
dockerRegistryRepoMap: {}
};
let npmciConfig = npmciNpmextra.dataFor('npmci', defaultConfig);
return npmciConfig;
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kuY29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtY2kuY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFFQSwyQ0FBMEM7QUFDMUM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FHLElBQUksT0FBTyxDQUFDLFFBQVEsQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFBO0FBQzVELElBQUksYUFBYSxHQUFrQjtJQUNqQyxjQUFjLEVBQUUsRUFBRTtJQUNsQixxQkFBcUIsRUFBRSxFQUFFO0NBQzFCLENBQUE7QUFDVSxRQUFBLFlBQVksR0FBRyxhQUFhLENBQUMsT0FBTyxDQUFnQixPQUFPLEVBQUUsYUFBYSxDQUFDLENBQUE7QUFFM0UsUUFBQSxTQUFTLEdBQUc7SUFDckIsTUFBTSxDQUFDLG9CQUFZLENBQUE7QUFDckIsQ0FBQyxDQUFBLENBQUEifQ==

View File

@ -1,6 +1,7 @@
import * as plugins from './mod.plugins' import * as plugins from './mod.plugins'
import * as paths from '../npmci.paths' import * as paths from '../npmci.paths'
import * as NpmciEnv from '../npmci.env' import * as NpmciEnv from '../npmci.env'
import * as NpmciConfig from '../npmci.config'
import { bash } from '../npmci.bash' import { bash } from '../npmci.bash'
import { Dockerfile } from './mod.classes.dockerfile' import { Dockerfile } from './mod.classes.dockerfile'
@ -130,13 +131,25 @@ export let dockerBaseImage = function (dockerfileContentArg: string) {
/** /**
* returns the docker tag * returns the docker tag
*/ */
export let getDockerTagString = function (registryArg: string, repoArg: string, versionArg: string, suffixArg?: string): string { export let getDockerTagString = (registryArg: string, repoArg: string, versionArg: string, suffixArg?: string): string => {
// determine wether the suffix is needed
// determine wether the repo should be mapped accordingly to the registry
let mappedRepo = NpmciConfig.configObject.dockerRegistryRepoMap[registryArg]
let repo = (() => {
if (mappedRepo) {
return mappedRepo
} else {
return repoArg
}
})()
// determine wether the version contais a suffix
let version = versionArg let version = versionArg
if (suffixArg) { if (suffixArg) {
version = versionArg + '_' + suffixArg version = versionArg + '_' + suffixArg
} }
let tagString = `${registryArg}/${repoArg}:${version}`
let tagString = `${registryArg}/${repo}:${version}`
return tagString return tagString
} }

View File

@ -15,12 +15,14 @@ export interface INpmciOptions {
// instantiate a kvStorage for the current directory // instantiate a kvStorage for the current directory
export let kvStorage = new KeyValueStore('custom', `${repo.user}_${repo.repo}`) export let kvStorage = new KeyValueStore('custom', `${repo.user}_${repo.repo}`)
export let getConfig = async (): Promise<INpmciOptions> => { // handle config retrival
let npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd) let npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd)
let defaultConfig: INpmciOptions = { let defaultConfig: INpmciOptions = {
npmGlobalTools: [], npmGlobalTools: [],
dockerRegistryRepoMap: {} dockerRegistryRepoMap: {}
} }
let npmciConfig = npmciNpmextra.dataFor<INpmciOptions>('npmci', defaultConfig) export let configObject = npmciNpmextra.dataFor<INpmciOptions>('npmci', defaultConfig)
return npmciConfig
export let getConfig = async (): Promise<INpmciOptions> => {
return configObject
} }