mirror of
https://github.com/caprover/caprover
synced 2026-08-22 23:46:33 +00:00
DataStore migrated
This commit is contained in:
@@ -1,37 +1,35 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Created by kasra on 27/06/17.
|
||||
*/
|
||||
const Configstore = require('configstore');
|
||||
const uuid = require('uuid/v4');
|
||||
const isValidPath = require('is-valid-path');
|
||||
const fs = require('fs-extra');
|
||||
const ApiStatusCodes = require('../api/ApiStatusCodes');
|
||||
const CaptainConstants = require('../utils/CaptainConstants');
|
||||
const Logger = require('../utils/Logger');
|
||||
const Encryptor = require('../utils/Encryptor');
|
||||
const AppsDataStore = require('./AppsDataStore');
|
||||
const NAMESPACE = 'namespace';
|
||||
const HASHED_PASSWORD = 'hashedPassword';
|
||||
const CAPTAIN_REGISTRY_AUTH_SECRET_VER = 'captainRegistryAuthSecretVer';
|
||||
const CUSTOM_DOMAIN = 'customDomain';
|
||||
const HAS_ROOT_SSL = 'hasRootSsl';
|
||||
const FORCE_ROOT_SSL = 'forceRootSsl';
|
||||
const HAS_REGISTRY_SSL = 'hasRegistrySsl';
|
||||
const HAS_LOCAL_REGISTRY = 'hasLocalRegistry';
|
||||
const EMAIL_ADDRESS = 'emailAddress';
|
||||
const DOCKER_REGISTRIES = 'dockerRegistries';
|
||||
const DEFAULT_DOCKER_REGISTRY = 'defaultDockerReg';
|
||||
const NET_DATA_INFO = 'netDataInfo';
|
||||
const NGINX_BASE_CONFIG = 'NGINX_BASE_CONFIG';
|
||||
const NGINX_CAPTAIN_CONFIG = 'NGINX_CAPTAIN_CONFIG';
|
||||
const DEFAULT_CAPTAIN_ROOT_DOMAIN = 'captain.localhost';
|
||||
const DEFAULT_NGINX_BASE_CONFIG = fs.readFileSync(__dirname + '/../../template/base-nginx-conf.ejs').toString();
|
||||
const DEFAULT_NGINX_CAPTAIN_CONFIG = fs.readFileSync(__dirname + '/../../template/root-nginx-conf.ejs').toString();
|
||||
const DEFAULT_NGINX_CONFIG_FOR_APP = fs.readFileSync(__dirname + '/../../template/server-block-conf.ejs').toString();
|
||||
const Configstore = require("configstore");
|
||||
const uuid = require("uuid/v4");
|
||||
const fs = require("fs-extra");
|
||||
const ApiStatusCodes = require("../api/ApiStatusCodes");
|
||||
const CaptainConstants = require("../utils/CaptainConstants");
|
||||
const AppsDataStore = require("./AppsDataStore");
|
||||
const NAMESPACE = "namespace";
|
||||
const HASHED_PASSWORD = "hashedPassword";
|
||||
const CAPTAIN_REGISTRY_AUTH_SECRET_VER = "captainRegistryAuthSecretVer";
|
||||
const CUSTOM_DOMAIN = "customDomain";
|
||||
const HAS_ROOT_SSL = "hasRootSsl";
|
||||
const FORCE_ROOT_SSL = "forceRootSsl";
|
||||
const HAS_REGISTRY_SSL = "hasRegistrySsl";
|
||||
const HAS_LOCAL_REGISTRY = "hasLocalRegistry";
|
||||
const EMAIL_ADDRESS = "emailAddress";
|
||||
const DOCKER_REGISTRIES = "dockerRegistries";
|
||||
const DEFAULT_DOCKER_REGISTRY = "defaultDockerReg";
|
||||
const NET_DATA_INFO = "netDataInfo";
|
||||
const NGINX_BASE_CONFIG = "NGINX_BASE_CONFIG";
|
||||
const NGINX_CAPTAIN_CONFIG = "NGINX_CAPTAIN_CONFIG";
|
||||
const DEFAULT_CAPTAIN_ROOT_DOMAIN = "captain.localhost";
|
||||
const DEFAULT_NGINX_BASE_CONFIG = fs.readFileSync(__dirname + "/../../template/base-nginx-conf.ejs").toString();
|
||||
const DEFAULT_NGINX_CAPTAIN_CONFIG = fs.readFileSync(__dirname + "/../../template/root-nginx-conf.ejs").toString();
|
||||
const DEFAULT_NGINX_CONFIG_FOR_APP = fs.readFileSync(__dirname + "/../../template/server-block-conf.ejs").toString();
|
||||
class DataStore {
|
||||
constructor(namespace) {
|
||||
let data = new Configstore('captain-store', {});
|
||||
data.path = CaptainConstants.captainRootDirectory + '/config.conf';
|
||||
const data = new Configstore("captain-store", {});
|
||||
data.path = CaptainConstants.captainRootDirectory + "/config.conf";
|
||||
this.data = data;
|
||||
this.data.set(NAMESPACE, namespace);
|
||||
this.appsDataStore = new AppsDataStore(this.data);
|
||||
@@ -80,7 +78,7 @@ class DataStore {
|
||||
const self = this;
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
let netDataInfo = self.data.get(NET_DATA_INFO) || {};
|
||||
const netDataInfo = self.data.get(NET_DATA_INFO) || {};
|
||||
netDataInfo.isEnabled = netDataInfo.isEnabled || false;
|
||||
netDataInfo.data = netDataInfo.data || {};
|
||||
return netDataInfo;
|
||||
@@ -108,23 +106,23 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
getServiceName(appName) {
|
||||
return 'srv-' + this.getNameSpace() + '--' + appName;
|
||||
return "srv-" + this.getNameSpace() + "--" + appName;
|
||||
}
|
||||
getImageName(authObj, appName, version) {
|
||||
let authPrefix = '';
|
||||
let authPrefix = "";
|
||||
if (authObj) {
|
||||
authPrefix = authObj.serveraddress + '/' + authObj.username + '/';
|
||||
authPrefix = authObj.serveraddress + "/" + authObj.username + "/";
|
||||
}
|
||||
return authPrefix + this.getImageNameWithoutAuthObj(appName, version);
|
||||
}
|
||||
getImageNameWithoutAuthObj(appName, version) {
|
||||
if (version === 0) {
|
||||
version = '0';
|
||||
getImageNameWithoutAuthObj(appName, versionStr) {
|
||||
if (versionStr === 0) {
|
||||
versionStr = "0";
|
||||
}
|
||||
return this.getImageNameBase() + appName + (version ? (':' + version) : '');
|
||||
return this.getImageNameBase() + appName + (versionStr ? (":" + versionStr) : "");
|
||||
}
|
||||
getImageNameBase() {
|
||||
return 'img-' + this.getNameSpace() + '--';
|
||||
return "img-" + this.getNameSpace() + "--";
|
||||
}
|
||||
getRootDomain() {
|
||||
return this.data.get(CUSTOM_DOMAIN) || DEFAULT_CAPTAIN_ROOT_DOMAIN;
|
||||
@@ -134,8 +132,8 @@ class DataStore {
|
||||
}
|
||||
getServerList() {
|
||||
const self = this;
|
||||
let hasRootSsl = null;
|
||||
let rootDomain = null;
|
||||
let hasRootSsl;
|
||||
let rootDomain;
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
return self.getHasRootSsl();
|
||||
@@ -169,7 +167,7 @@ class DataStore {
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
let found = false;
|
||||
let registries = self.data.get(DOCKER_REGISTRIES) || [];
|
||||
const registries = self.data.get(DOCKER_REGISTRIES) || [];
|
||||
for (let i = 0; i < registries.length; i++) {
|
||||
const registry = registries[i];
|
||||
if (registry.id === registryId) {
|
||||
@@ -178,7 +176,7 @@ class DataStore {
|
||||
}
|
||||
// registryId can be NULL/Empty, meaning that no registry will be the default push registry
|
||||
if (!found && !!registryId) {
|
||||
throw ApiStatusCodes.createError(ApiStatusCodes.NOT_FOUND, 'Registry not found');
|
||||
throw ApiStatusCodes.createError(ApiStatusCodes.NOT_FOUND, "Registry not found");
|
||||
}
|
||||
self.data.set(DEFAULT_DOCKER_REGISTRY, registryId);
|
||||
});
|
||||
@@ -187,8 +185,8 @@ class DataStore {
|
||||
const self = this;
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
let newReg = [];
|
||||
let registries = self.data.get(DOCKER_REGISTRIES) || [];
|
||||
const newReg = [];
|
||||
const registries = self.data.get(DOCKER_REGISTRIES) || [];
|
||||
for (let i = 0; i < registries.length; i++) {
|
||||
const registry = registries[i];
|
||||
if (registry.id !== registryId) {
|
||||
@@ -196,7 +194,7 @@ class DataStore {
|
||||
}
|
||||
}
|
||||
if (newReg.length === registries.length) {
|
||||
throw ApiStatusCodes.createError(ApiStatusCodes.NOT_FOUND, 'Registry not found');
|
||||
throw ApiStatusCodes.createError(ApiStatusCodes.NOT_FOUND, "Registry not found");
|
||||
}
|
||||
self.data.set(DOCKER_REGISTRIES, newReg);
|
||||
});
|
||||
@@ -217,7 +215,7 @@ class DataStore {
|
||||
});
|
||||
})
|
||||
.then(function (registries) {
|
||||
let id = null;
|
||||
let id = uuid();
|
||||
let isAlreadyTaken = true;
|
||||
while (isAlreadyTaken) {
|
||||
id = uuid();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -153,7 +153,7 @@ class DockerRegistry {
|
||||
updateRegistryAuthHeader(username, password, domain, currentVersion) {
|
||||
const self = this;
|
||||
const dockerApi = this.dockerApi;
|
||||
let nextVersion = undefined;
|
||||
let nextVersion;
|
||||
let secretName = undefined;
|
||||
let userEmailAddress = undefined;
|
||||
return Promise.resolve()
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -124,7 +124,7 @@ class ServiceManager {
|
||||
createImage(appName, source, gitHash) {
|
||||
Logger.d("Creating image for: " + appName);
|
||||
const self = this;
|
||||
const imageName = this.dataStore.getImageName(CaptainManager.get().getDockerAuthObject(), appName);
|
||||
const imageName = this.dataStore.getImageName(CaptainManager.get().getDockerAuthObject(), appName, undefined);
|
||||
const dockerApi = this.dockerApi;
|
||||
const dataStore = this.dataStore;
|
||||
let newVersion;
|
||||
|
||||
File diff suppressed because one or more lines are too long
Generated
+5
@@ -47,6 +47,11 @@
|
||||
"resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.1.tgz",
|
||||
"integrity": "sha512-FhlMa34NHp9K5MY1Uz8yb+ZvuX0pnvn3jScRSNAb75KHGB8d3rEU6hqMs3Z2vjuytcMfRg6c5CHMc3wtYyD2/A=="
|
||||
},
|
||||
"@types/configstore": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/configstore/-/configstore-2.1.1.tgz",
|
||||
"integrity": "sha1-zR6FU2M60xhcPy8jns/10mQ+krY="
|
||||
},
|
||||
"@types/ejs": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-2.6.0.tgz",
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/bcryptjs": "^2.4.2",
|
||||
"@types/configstore": "^2.1.1",
|
||||
"@types/ejs": "^2.6.0",
|
||||
"@types/fs-extra": "^5.0.4",
|
||||
"@types/jsonwebtoken": "^8.3.0",
|
||||
|
||||
+74
-73
@@ -1,42 +1,43 @@
|
||||
/**
|
||||
* Created by kasra on 27/06/17.
|
||||
*/
|
||||
const Configstore = require('configstore');
|
||||
const uuid = require('uuid/v4');
|
||||
const isValidPath = require('is-valid-path');
|
||||
const fs = require('fs-extra');
|
||||
const ApiStatusCodes = require('../api/ApiStatusCodes');
|
||||
const CaptainConstants = require('../utils/CaptainConstants');
|
||||
const Logger = require('../utils/Logger');
|
||||
const Encryptor = require('../utils/Encryptor');
|
||||
const AppsDataStore = require('./AppsDataStore');
|
||||
import Configstore = require("configstore");
|
||||
import uuid = require("uuid/v4");
|
||||
import fs = require("fs-extra");
|
||||
import ApiStatusCodes = require("../api/ApiStatusCodes");
|
||||
import CaptainConstants = require("../utils/CaptainConstants");
|
||||
import Logger = require("../utils/Logger");
|
||||
import Encryptor = require("../utils/Encryptor");
|
||||
import AppsDataStore = require("./AppsDataStore");
|
||||
|
||||
const NAMESPACE = 'namespace';
|
||||
const HASHED_PASSWORD = 'hashedPassword';
|
||||
const CAPTAIN_REGISTRY_AUTH_SECRET_VER = 'captainRegistryAuthSecretVer';
|
||||
const CUSTOM_DOMAIN = 'customDomain';
|
||||
const HAS_ROOT_SSL = 'hasRootSsl';
|
||||
const FORCE_ROOT_SSL = 'forceRootSsl';
|
||||
const HAS_REGISTRY_SSL = 'hasRegistrySsl';
|
||||
const HAS_LOCAL_REGISTRY = 'hasLocalRegistry';
|
||||
const EMAIL_ADDRESS = 'emailAddress';
|
||||
const DOCKER_REGISTRIES = 'dockerRegistries';
|
||||
const DEFAULT_DOCKER_REGISTRY = 'defaultDockerReg';
|
||||
const NET_DATA_INFO = 'netDataInfo';
|
||||
const NGINX_BASE_CONFIG = 'NGINX_BASE_CONFIG';
|
||||
const NGINX_CAPTAIN_CONFIG = 'NGINX_CAPTAIN_CONFIG';
|
||||
const DEFAULT_CAPTAIN_ROOT_DOMAIN = 'captain.localhost';
|
||||
const NAMESPACE = "namespace";
|
||||
const HASHED_PASSWORD = "hashedPassword";
|
||||
const CAPTAIN_REGISTRY_AUTH_SECRET_VER = "captainRegistryAuthSecretVer";
|
||||
const CUSTOM_DOMAIN = "customDomain";
|
||||
const HAS_ROOT_SSL = "hasRootSsl";
|
||||
const FORCE_ROOT_SSL = "forceRootSsl";
|
||||
const HAS_REGISTRY_SSL = "hasRegistrySsl";
|
||||
const HAS_LOCAL_REGISTRY = "hasLocalRegistry";
|
||||
const EMAIL_ADDRESS = "emailAddress";
|
||||
const DOCKER_REGISTRIES = "dockerRegistries";
|
||||
const DEFAULT_DOCKER_REGISTRY = "defaultDockerReg";
|
||||
const NET_DATA_INFO = "netDataInfo";
|
||||
const NGINX_BASE_CONFIG = "NGINX_BASE_CONFIG";
|
||||
const NGINX_CAPTAIN_CONFIG = "NGINX_CAPTAIN_CONFIG";
|
||||
const DEFAULT_CAPTAIN_ROOT_DOMAIN = "captain.localhost";
|
||||
|
||||
const DEFAULT_NGINX_BASE_CONFIG = fs.readFileSync(__dirname + '/../../template/base-nginx-conf.ejs').toString();
|
||||
const DEFAULT_NGINX_CAPTAIN_CONFIG = fs.readFileSync(__dirname + '/../../template/root-nginx-conf.ejs').toString();
|
||||
const DEFAULT_NGINX_CONFIG_FOR_APP = fs.readFileSync(__dirname + '/../../template/server-block-conf.ejs').toString();
|
||||
const DEFAULT_NGINX_BASE_CONFIG = fs.readFileSync(__dirname + "/../../template/base-nginx-conf.ejs").toString();
|
||||
const DEFAULT_NGINX_CAPTAIN_CONFIG = fs.readFileSync(__dirname + "/../../template/root-nginx-conf.ejs").toString();
|
||||
const DEFAULT_NGINX_CONFIG_FOR_APP = fs.readFileSync(__dirname + "/../../template/server-block-conf.ejs").toString();
|
||||
|
||||
class DataStore {
|
||||
|
||||
constructor(namespace) {
|
||||
private data: Configstore;
|
||||
private appsDataStore: AppsDataStore;
|
||||
constructor(namespace: string) {
|
||||
|
||||
let data = new Configstore('captain-store', {});
|
||||
data.path = CaptainConstants.captainRootDirectory + '/config.conf';
|
||||
const data = new Configstore("captain-store", {});
|
||||
data.path = CaptainConstants.captainRootDirectory + "/config.conf";
|
||||
|
||||
this.data = data;
|
||||
this.data.set(NAMESPACE, namespace);
|
||||
@@ -47,11 +48,11 @@ class DataStore {
|
||||
return this.data.get(NAMESPACE);
|
||||
}
|
||||
|
||||
setHashedPassword(newHashedPassword) {
|
||||
setHashedPassword(newHashedPassword: string) {
|
||||
const self = this;
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
return self.data.set(HASHED_PASSWORD, newHashedPassword)
|
||||
return self.data.set(HASHED_PASSWORD, newHashedPassword);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,7 +60,7 @@ class DataStore {
|
||||
const self = this;
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
return self.data.get(HASHED_PASSWORD)
|
||||
return self.data.get(HASHED_PASSWORD);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,26 +91,26 @@ class DataStore {
|
||||
const self = this;
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
let netDataInfo = self.data.get(NET_DATA_INFO) || {};
|
||||
const netDataInfo = self.data.get(NET_DATA_INFO) || {};
|
||||
netDataInfo.isEnabled = netDataInfo.isEnabled || false;
|
||||
netDataInfo.data = netDataInfo.data || {};
|
||||
return netDataInfo;
|
||||
});
|
||||
}
|
||||
|
||||
setNetDataInfo(netDataInfo) {
|
||||
setNetDataInfo(netDataInfo: NetDataInfo) {
|
||||
const self = this;
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
return self.data.set(NET_DATA_INFO, netDataInfo)
|
||||
return self.data.set(NET_DATA_INFO, netDataInfo);
|
||||
});
|
||||
}
|
||||
|
||||
setRegistryAuthSecretVersion(ver) {
|
||||
setRegistryAuthSecretVersion(ver: number) {
|
||||
const self = this;
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
return self.data.set(CAPTAIN_REGISTRY_AUTH_SECRET_VER, Number(ver))
|
||||
return self.data.set(CAPTAIN_REGISTRY_AUTH_SECRET_VER, Number(ver));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -121,32 +122,32 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
|
||||
getServiceName(appName) {
|
||||
return 'srv-' + this.getNameSpace() + '--' + appName;
|
||||
getServiceName(appName: string) {
|
||||
return "srv-" + this.getNameSpace() + "--" + appName;
|
||||
}
|
||||
|
||||
getImageName(authObj, appName, version) {
|
||||
getImageName(authObj: any, appName: string, version: string|undefined|number) {
|
||||
|
||||
let authPrefix = '';
|
||||
let authPrefix = "";
|
||||
|
||||
if (authObj) {
|
||||
authPrefix = authObj.serveraddress + '/' + authObj.username + '/';
|
||||
authPrefix = authObj.serveraddress + "/" + authObj.username + "/";
|
||||
}
|
||||
|
||||
return authPrefix + this.getImageNameWithoutAuthObj(appName, version);
|
||||
}
|
||||
|
||||
getImageNameWithoutAuthObj(appName, version) {
|
||||
getImageNameWithoutAuthObj(appName: string, versionStr: string|undefined|number) {
|
||||
|
||||
if (version === 0) {
|
||||
version = '0';
|
||||
if (versionStr === 0) {
|
||||
versionStr = "0";
|
||||
}
|
||||
|
||||
return this.getImageNameBase() + appName + (version ? (':' + version) : '');
|
||||
return this.getImageNameBase() + appName + (versionStr ? (":" + versionStr) : "");
|
||||
}
|
||||
|
||||
getImageNameBase() {
|
||||
return 'img-' + this.getNameSpace() + '--';
|
||||
return "img-" + this.getNameSpace() + "--";
|
||||
}
|
||||
|
||||
getRootDomain() {
|
||||
@@ -161,8 +162,8 @@ class DataStore {
|
||||
|
||||
const self = this;
|
||||
|
||||
let hasRootSsl = null;
|
||||
let rootDomain = null;
|
||||
let hasRootSsl: boolean;
|
||||
let rootDomain: boolean;
|
||||
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
@@ -170,7 +171,7 @@ class DataStore {
|
||||
return self.getHasRootSsl();
|
||||
|
||||
})
|
||||
.then(function (val) {
|
||||
.then(function (val: boolean) {
|
||||
|
||||
hasRootSsl = val;
|
||||
|
||||
@@ -210,7 +211,7 @@ class DataStore {
|
||||
|
||||
}
|
||||
|
||||
setDefaultPushRegistry(registryId) {
|
||||
setDefaultPushRegistry(registryId: string) {
|
||||
|
||||
const self = this;
|
||||
|
||||
@@ -218,7 +219,7 @@ class DataStore {
|
||||
.then(function () {
|
||||
|
||||
let found = false;
|
||||
let registries = self.data.get(DOCKER_REGISTRIES) || [];
|
||||
const registries = self.data.get(DOCKER_REGISTRIES) || [];
|
||||
for (let i = 0; i < registries.length; i++) {
|
||||
const registry = registries[i];
|
||||
if (registry.id === registryId) {
|
||||
@@ -228,7 +229,7 @@ class DataStore {
|
||||
|
||||
// registryId can be NULL/Empty, meaning that no registry will be the default push registry
|
||||
if (!found && !!registryId) {
|
||||
throw ApiStatusCodes.createError(ApiStatusCodes.NOT_FOUND, 'Registry not found');
|
||||
throw ApiStatusCodes.createError(ApiStatusCodes.NOT_FOUND, "Registry not found");
|
||||
}
|
||||
|
||||
self.data.set(DEFAULT_DOCKER_REGISTRY, registryId);
|
||||
@@ -236,15 +237,15 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
|
||||
deleteRegistry(registryId) {
|
||||
deleteRegistry(registryId: string) {
|
||||
|
||||
const self = this;
|
||||
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
|
||||
let newReg = [];
|
||||
let registries = self.data.get(DOCKER_REGISTRIES) || [];
|
||||
const newReg = [];
|
||||
const registries = self.data.get(DOCKER_REGISTRIES) || [];
|
||||
for (let i = 0; i < registries.length; i++) {
|
||||
const registry = registries[i];
|
||||
if (registry.id !== registryId) {
|
||||
@@ -253,7 +254,7 @@ class DataStore {
|
||||
}
|
||||
|
||||
if (newReg.length === registries.length) {
|
||||
throw ApiStatusCodes.createError(ApiStatusCodes.NOT_FOUND, 'Registry not found');
|
||||
throw ApiStatusCodes.createError(ApiStatusCodes.NOT_FOUND, "Registry not found");
|
||||
}
|
||||
|
||||
self.data.set(DOCKER_REGISTRIES, newReg);
|
||||
@@ -273,7 +274,7 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
|
||||
addRegistryToDb(registryUser, registryPasswordEncrypted, registryDomain, registryImagePrefix) {
|
||||
addRegistryToDb(registryUser: string, registryPasswordEncrypted: string, registryDomain: string, registryImagePrefix: string) {
|
||||
|
||||
const self = this;
|
||||
|
||||
@@ -283,11 +284,11 @@ class DataStore {
|
||||
|
||||
resolve(self.data.get(DOCKER_REGISTRIES) || []);
|
||||
|
||||
})
|
||||
});
|
||||
})
|
||||
.then(function (registries) {
|
||||
.then(function (registries: any[]) {
|
||||
|
||||
let id = null;
|
||||
let id: string = uuid();
|
||||
let isAlreadyTaken = true;
|
||||
|
||||
while (isAlreadyTaken) {
|
||||
@@ -315,7 +316,7 @@ class DataStore {
|
||||
|
||||
}
|
||||
|
||||
setUserEmailAddress(emailAddress) {
|
||||
setUserEmailAddress(emailAddress: string) {
|
||||
|
||||
const self = this;
|
||||
|
||||
@@ -328,7 +329,7 @@ class DataStore {
|
||||
|
||||
}
|
||||
|
||||
getUserEmailAddress() {
|
||||
getUserEmailAddress(): Promise<string|undefined> {
|
||||
|
||||
const self = this;
|
||||
|
||||
@@ -339,7 +340,7 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
|
||||
setHasRootSsl(hasRootSsl) {
|
||||
setHasRootSsl(hasRootSsl: boolean) {
|
||||
|
||||
const self = this;
|
||||
|
||||
@@ -351,7 +352,7 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
|
||||
setForceSsl(forceSsl) {
|
||||
setForceSsl(forceSsl: boolean) {
|
||||
const self = this;
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
@@ -362,7 +363,7 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
|
||||
getForceSsl() {
|
||||
getForceSsl(): Promise<boolean> {
|
||||
|
||||
const self = this;
|
||||
|
||||
@@ -373,7 +374,7 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
|
||||
setHasRegistrySsl(hasRegistrySsl) {
|
||||
setHasRegistrySsl(hasRegistrySsl: boolean) {
|
||||
|
||||
const self = this;
|
||||
|
||||
@@ -414,7 +415,7 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
|
||||
setNginxConfig(baseConfig, captainConfig) {
|
||||
setNginxConfig(baseConfig: string, captainConfig: string) {
|
||||
|
||||
const self = this;
|
||||
|
||||
@@ -425,7 +426,7 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
|
||||
getHasRootSsl() {
|
||||
getHasRootSsl(): Promise<boolean> {
|
||||
|
||||
const self = this;
|
||||
|
||||
@@ -436,7 +437,7 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
|
||||
setHasLocalRegistry(hasLocalRegistry) {
|
||||
setHasLocalRegistry(hasLocalRegistry: boolean) {
|
||||
|
||||
const self = this;
|
||||
|
||||
@@ -466,7 +467,7 @@ class DataStore {
|
||||
});
|
||||
}
|
||||
|
||||
setCustomDomain(customDomain) {
|
||||
setCustomDomain(customDomain: string) {
|
||||
|
||||
const self = this;
|
||||
|
||||
@@ -480,4 +481,4 @@ class DataStore {
|
||||
|
||||
}
|
||||
|
||||
module.exports = DataStore;
|
||||
export = DataStore;
|
||||
@@ -213,7 +213,7 @@ class DockerRegistry {
|
||||
const self = this;
|
||||
const dockerApi = this.dockerApi;
|
||||
|
||||
let nextVersion: number|undefined = undefined;
|
||||
let nextVersion: number;
|
||||
|
||||
let secretName: string|undefined = undefined;
|
||||
|
||||
@@ -256,7 +256,7 @@ class DockerRegistry {
|
||||
username,
|
||||
password,
|
||||
domain,
|
||||
nextVersion!
|
||||
nextVersion
|
||||
);
|
||||
} else {
|
||||
return dockerApi
|
||||
|
||||
@@ -164,7 +164,7 @@ class ServiceManager {
|
||||
|
||||
const self = this;
|
||||
|
||||
const imageName = this.dataStore.getImageName(CaptainManager.get().getDockerAuthObject(), appName);
|
||||
const imageName = this.dataStore.getImageName(CaptainManager.get().getDockerAuthObject(), appName, undefined);
|
||||
const dockerApi = this.dockerApi;
|
||||
const dataStore = this.dataStore;
|
||||
let newVersion: number;
|
||||
|
||||
Reference in New Issue
Block a user