some cosmetics
This commit is contained in:
parent
94e7f502b3
commit
3653373f12
23
dist/npmci.ssh.js
vendored
23
dist/npmci.ssh.js
vendored
@ -7,23 +7,38 @@ exports.ssh = function () {
|
||||
var done = plugins.q.defer();
|
||||
sshInstance = new plugins.smartssh.SshInstance();
|
||||
plugins.smartparam.forEachMinimatch(process.env, "NPMCI_SSHKEY_*", evaluateSshEnv);
|
||||
if (!process.env.NPMTS_TEST) {
|
||||
sshInstance.writeToDisk();
|
||||
}
|
||||
else {
|
||||
plugins.beautylog.log("In test mode, so not storing SSH keys to disk!");
|
||||
}
|
||||
;
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
var evaluateSshEnv = function (sshkeyEnvVarArg) {
|
||||
var resultArray = sshRegex.exec(sshkeyEnvVarArg);
|
||||
var sshKey = new plugins.smartssh.SshKey();
|
||||
if (notUndefined(resultArray[1]))
|
||||
plugins.beautylog.info("Found SSH identity for " + resultArray[1]);
|
||||
if (notUndefined(resultArray[1])) {
|
||||
plugins.beautylog.log("---> host defined!");
|
||||
sshKey.host = resultArray[1];
|
||||
if (notUndefined(resultArray[2]))
|
||||
}
|
||||
if (notUndefined(resultArray[2])) {
|
||||
plugins.beautylog.log("---> privKey defined!");
|
||||
sshKey.privKeyBase64 = resultArray[2];
|
||||
if (notUndefined(resultArray[3]))
|
||||
}
|
||||
;
|
||||
if (notUndefined(resultArray[3])) {
|
||||
"---> pubKey defined!";
|
||||
sshKey.pubKeyBase64 = resultArray[3];
|
||||
}
|
||||
;
|
||||
sshInstance.addKey(sshKey);
|
||||
};
|
||||
var notUndefined = function (stringArg) {
|
||||
return (stringArg && stringArg != "undefined" && stringArg != "##");
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLnNzaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQU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ZmluZWQocmVzdWx0QXJyYXlbMl0pKXtcbiAgICAgICAgcGx1Z2lucy5iZWF1dHlsb2cubG9nKFwiLS0tPiBwcml2S2V5IGRlZmluZWQhXCIpXG4gICAgICAgIHNzaEtleS5wcml2S2V5QmFzZTY0ID0gcmVzdWx0QXJyYXlbMl07XG4gICAgfTtcbiAgICBpZihub3RVbmRlZmluZWQocmVzdWx0QXJyYXlbM10pKXtcbiAgICAgICAgXCItLS0+IHB1YktleSBkZWZpbmVkIVwiXG4gICAgICAgIHNzaEtleS5wdWJLZXlCYXNlNjQgPSByZXN1bHRBcnJheVszXTtcbiAgICB9O1xuICAgIFxuICAgIHNzaEluc3RhbmNlLmFkZEtleShzc2hLZXkpO1xufTtcblxubGV0IG5vdFVuZGVmaW5lZCA9IChzdHJpbmdBcmc6c3RyaW5nKSA9PiB7XG4gICAgcmV0dXJuIChzdHJpbmdBcmcgJiYgc3RyaW5nQXJnICE9IFwidW5kZWZpbmVkXCIgJiYgc3RyaW5nQXJnICE9IFwiIyNcIik7XG59Il19
|
||||
|
12
test/test.js
12
test/test.js
File diff suppressed because one or more lines are too long
10
test/test.ts
10
test/test.ts
@ -4,6 +4,7 @@ import path = require("path");
|
||||
import * as beautylog from "beautylog"
|
||||
//set up environment
|
||||
process.env.CI_BUILD_REPO = "https://yyyyyy:xxxxxxxx@gitlab.com/mygroup/myrepo.git";
|
||||
process.env.NPMCI_SSHKEY_1 = "hostString|somePrivKey|##"
|
||||
process.env.NPMTS_TEST = "true";
|
||||
process.cwd = () => {
|
||||
return path.join(__dirname,"assets/");
|
||||
@ -14,6 +15,7 @@ import npmci = require("../dist/index");
|
||||
import NpmciBuildDocker = require("../dist/npmci.build.docker");
|
||||
import NpmciPublish = require("../dist/npmci.publish");
|
||||
import NpmciTest = require("../dist/npmci.test");
|
||||
import NpmciSsh = require("../dist/npmci.ssh")
|
||||
|
||||
|
||||
let dockerfile1:NpmciBuildDocker.Dockerfile;
|
||||
@ -81,4 +83,12 @@ describe("NPMCI",function(){
|
||||
});
|
||||
})
|
||||
});
|
||||
describe("npmci prepare ssh",function(){
|
||||
it("should pick up SSH keys",function(done){
|
||||
NpmciSsh.ssh()
|
||||
.then(() => {
|
||||
done();
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
@ -8,7 +8,11 @@ export let ssh = () => {
|
||||
let done = plugins.q.defer();
|
||||
sshInstance = new plugins.smartssh.SshInstance();
|
||||
plugins.smartparam.forEachMinimatch(process.env,"NPMCI_SSHKEY_*",evaluateSshEnv);
|
||||
sshInstance.writeToDisk();
|
||||
if(!process.env.NPMTS_TEST){
|
||||
sshInstance.writeToDisk()
|
||||
} else {
|
||||
plugins.beautylog.log("In test mode, so not storing SSH keys to disk!");
|
||||
};
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
@ -16,14 +20,23 @@ export let ssh = () => {
|
||||
let evaluateSshEnv = (sshkeyEnvVarArg) => {
|
||||
let resultArray = sshRegex.exec(sshkeyEnvVarArg);
|
||||
let sshKey = new plugins.smartssh.SshKey();
|
||||
|
||||
if(notUndefined(resultArray[1])) sshKey.host = resultArray[1];
|
||||
if(notUndefined(resultArray[2])) sshKey.privKeyBase64 = resultArray[2];
|
||||
if(notUndefined(resultArray[3])) sshKey.pubKeyBase64 = resultArray[3];
|
||||
plugins.beautylog.info("Found SSH identity for " + resultArray[1]);
|
||||
if(notUndefined(resultArray[1])){
|
||||
plugins.beautylog.log("---> host defined!")
|
||||
sshKey.host = resultArray[1];
|
||||
}
|
||||
if(notUndefined(resultArray[2])){
|
||||
plugins.beautylog.log("---> privKey defined!")
|
||||
sshKey.privKeyBase64 = resultArray[2];
|
||||
};
|
||||
if(notUndefined(resultArray[3])){
|
||||
"---> pubKey defined!"
|
||||
sshKey.pubKeyBase64 = resultArray[3];
|
||||
};
|
||||
|
||||
sshInstance.addKey(sshKey);
|
||||
};
|
||||
|
||||
let notUndefined = (stringArg:string) => {
|
||||
return (stringArg && stringArg != "undefined" && stringArg != "##")
|
||||
return (stringArg && stringArg != "undefined" && stringArg != "##");
|
||||
}
|
Loading…
Reference in New Issue
Block a user