kopia lustrzana https://github.com/c9/core
support both nameing schemes
rodzic
1300bff8ab
commit
b6c0d9fd06
|
@ -1,14 +1,30 @@
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
|
||||||
exports.parse = function(hostname) {
|
exports.parse = function(hostname) {
|
||||||
var parts = hostname.split("-");
|
|
||||||
return {
|
var m1 = hostname.match(/^([0-9a-z-]+?)-gce-([a-z]+)-([0-9]+)-([a-z0-9]+)$/);
|
||||||
type: parts[0],
|
var m2 = hostname.match(/^([0-9a-z-]+?)-gce-([a-z]+)-([a-z0-9]+)-([a-z0-9]{4})$/);
|
||||||
provider: parts[1],
|
|
||||||
region: parts[2],
|
if (m1) {
|
||||||
index: parts[5] || parts[3],
|
return {
|
||||||
env: parts[4]
|
type: m1[1],
|
||||||
};
|
provider: "gce",
|
||||||
|
region: m1[2],
|
||||||
|
index: m1[3],
|
||||||
|
env: m1[4]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if (m2) {
|
||||||
|
return {
|
||||||
|
type: m2[1],
|
||||||
|
provider: "gce",
|
||||||
|
region: m2[2],
|
||||||
|
env: m2[3],
|
||||||
|
index: m2[4]
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.get = function() {
|
exports.get = function() {
|
||||||
|
|
Ładowanie…
Reference in New Issue