mirror of
https://github.com/caprover/caprover
synced 2026-09-26 00:25:38 +00:00
Updated linter
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
# don't ever lint node_modules
|
||||
node_modules
|
||||
# don't lint build output (make sure it's set to your correct build folder name)
|
||||
built
|
||||
# don't lint nyc coverage output
|
||||
coverage
|
||||
@@ -0,0 +1,26 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: [
|
||||
'@typescript-eslint',
|
||||
],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-this-alias": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/no-unused-vars": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-empty-interface": "off",
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/ban-types": "off",
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"no-case-declarations": "off",
|
||||
"no-useless-escape": "off",
|
||||
|
||||
}
|
||||
};
|
||||
@@ -1,19 +1,19 @@
|
||||
name: Run build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 10
|
||||
- run: sudo mkdir /captain && npm ci && npm run build && sudo npm run test
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 10
|
||||
- run: sudo mkdir /captain && npm ci && npm run build && sudo npm run test
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
name: Run formatter
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
check-code-formatting:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 10
|
||||
- run: npm ci && npm run formatter
|
||||
check-code-formatting:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 10
|
||||
- run: npm ci && npm run formatter
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
name: Run lint
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
run-tslint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 10
|
||||
- run: npm ci && npm run tslint
|
||||
run-lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 10
|
||||
- run: npm ci && npm run lint
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
sudo mkdir /captain
|
||||
npm ci
|
||||
npm run build
|
||||
npm run tslint
|
||||
npm run lint
|
||||
npm run formatter
|
||||
sudo npm run test
|
||||
build-publish-docker-hub:
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
sudo mkdir /captain
|
||||
npm ci
|
||||
npm run build
|
||||
npm run tslint
|
||||
npm run lint
|
||||
npm run formatter
|
||||
sudo npm run test
|
||||
build-publish-docker-hub:
|
||||
|
||||
Vendored
-1
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"eg2.tslint",
|
||||
"streetsidesoftware.code-spell-checker",
|
||||
"pflannery.vscode-versionlens",
|
||||
"remimarsal.prettier-now",
|
||||
|
||||
Vendored
+3
-5
@@ -3,17 +3,15 @@
|
||||
"search.exclude": {
|
||||
"**/node_modules": true,
|
||||
"**/bower_components": true,
|
||||
"**/dist": true,
|
||||
"**/built": true,
|
||||
"**/coverge": true
|
||||
},
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports": true
|
||||
"source.organizeImports": true,
|
||||
"source.fixAll.eslint": true
|
||||
},
|
||||
"typescript.referencesCodeLens.enabled": true,
|
||||
"tslint.ignoreDefinitionFiles": false,
|
||||
"tslint.autoFixOnSave": true,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"tslint.exclude": "**/node_modules/**/*",
|
||||
"cSpell.words": ["csrf", "definitelytyped", "promisified"]
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-undef */
|
||||
module.exports = {
|
||||
transform: {
|
||||
"^.+\\.tsx?$": "ts-jest",
|
||||
|
||||
Generated
+1957
-3567
File diff suppressed because it is too large
Load Diff
+7
-4
@@ -6,7 +6,8 @@
|
||||
"start": "node ./built/server.js",
|
||||
"dev": "npm run build && sudo ./dev-scripts/dev-reset-service.sh",
|
||||
"clean": "npm run build && sudo ./dev-scripts/dev-clean-run-as-dev.sh",
|
||||
"tslint": "tslint -c tslint.json -p tsconfig.json",
|
||||
"lint": "eslint -c .eslintrc.js --ext .ts ./src",
|
||||
"lint-fix": "eslint --fix -c .eslintrc.js --ext .ts ./src",
|
||||
"formatter": "prettier --check './src/**/*.ts'",
|
||||
"formatter-write": "prettier --write './src/**/*.ts'",
|
||||
"build": "echo 'RECOMPILING' && npx madge --circular --extensions ts ./ && rm -rf ./built && npx tsc && echo 'Build successful'",
|
||||
@@ -62,14 +63,16 @@
|
||||
"simple-git": "^2.45.0",
|
||||
"ssh2": "^1.3.0",
|
||||
"tar": "^6.1.11",
|
||||
"tslint": "^6.1.3",
|
||||
"typescript": "^4.4.2",
|
||||
"uuid": "^8.3.2",
|
||||
"validator": "^13.6.0",
|
||||
"yaml": "^1.10.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^4.29.3",
|
||||
"@typescript-eslint/parser": "^4.29.3",
|
||||
"eslint": "^7.32.0",
|
||||
"jest": "^27.1.0",
|
||||
"ts-jest": "^27.0.5"
|
||||
"ts-jest": "^27.0.5",
|
||||
"typescript": "^4.3.5"
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -22,7 +22,7 @@ import Utils from './utils/Utils'
|
||||
|
||||
const httpProxy = httpProxyImport.createProxyServer({})
|
||||
|
||||
let app = express()
|
||||
const app = express()
|
||||
|
||||
app.set('views', path.join(__dirname, '../views'))
|
||||
app.set('view engine', 'ejs')
|
||||
@@ -77,11 +77,11 @@ app.use(Injector.injectGlobal())
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
if (InjectionExtractor.extractGlobalsFromInjected(res).forceSsl) {
|
||||
let isRequestSsl =
|
||||
const isRequestSsl =
|
||||
req.secure || req.get('X-Forwarded-Proto') === 'https'
|
||||
|
||||
if (!isRequestSsl) {
|
||||
let newUrl = `https://${req.get('host')}${req.originalUrl}`
|
||||
const newUrl = `https://${req.get('host')}${req.originalUrl}`
|
||||
res.redirect(302, newUrl)
|
||||
return
|
||||
}
|
||||
@@ -105,10 +105,10 @@ app.use(CaptainConstants.netDataRelativePath, function (req, res, next) {
|
||||
req.originalUrl.indexOf(CaptainConstants.netDataRelativePath + '/') !==
|
||||
0
|
||||
) {
|
||||
let isRequestSsl =
|
||||
const isRequestSsl =
|
||||
req.secure || req.get('X-Forwarded-Proto') === 'https'
|
||||
|
||||
let newUrl =
|
||||
const newUrl =
|
||||
(isRequestSsl ? 'https://' : 'http://') +
|
||||
req.get('host') +
|
||||
CaptainConstants.netDataRelativePath +
|
||||
@@ -173,7 +173,7 @@ app.use(CaptainConstants.netDataRelativePath, function (req, res, next) {
|
||||
|
||||
// ********************* Beginning of API End Points *******************************************
|
||||
|
||||
let API_PREFIX = '/api/'
|
||||
const API_PREFIX = '/api/'
|
||||
|
||||
app.use(API_PREFIX + ':apiVersionFromRequest/', function (req, res, next) {
|
||||
if (req.params.apiVersionFromRequest !== CaptainConstants.apiVersion) {
|
||||
@@ -187,7 +187,7 @@ app.use(API_PREFIX + ':apiVersionFromRequest/', function (req, res, next) {
|
||||
}
|
||||
|
||||
if (!InjectionExtractor.extractGlobalsFromInjected(res).initialized) {
|
||||
let response = new BaseApi(
|
||||
const response = new BaseApi(
|
||||
ApiStatusCodes.STATUS_ERROR_CAPTAIN_NOT_INITIALIZED,
|
||||
'Captain is not ready yet...'
|
||||
)
|
||||
|
||||
@@ -37,7 +37,7 @@ class AppsDataStore {
|
||||
this.encryptor = encryptor
|
||||
}
|
||||
|
||||
private saveApp(appName: String, app: IAppDef) {
|
||||
private saveApp(appName: string, app: IAppDef) {
|
||||
const self = this
|
||||
|
||||
return Promise.resolve()
|
||||
@@ -205,7 +205,7 @@ class AppsDataStore {
|
||||
)
|
||||
}
|
||||
|
||||
if (!!this.data.get(`${APP_DEFINITIONS}.${appName}`)) {
|
||||
if (this.data.get(`${APP_DEFINITIONS}.${appName}`)) {
|
||||
throw ApiStatusCodes.createError(
|
||||
ApiStatusCodes.STATUS_ERROR_ALREADY_EXIST,
|
||||
'App Name already exists. Please use a different name'
|
||||
@@ -264,8 +264,8 @@ class AppsDataStore {
|
||||
getAppDefinitions() {
|
||||
const self = this
|
||||
return new Promise<IAllAppDefinitions>(function (resolve, reject) {
|
||||
let allApps = self.data.get(APP_DEFINITIONS) || {}
|
||||
let allAppsUnencrypted: IAllAppDefinitions = {}
|
||||
const allApps = self.data.get(APP_DEFINITIONS) || {}
|
||||
const allAppsUnencrypted: IAllAppDefinitions = {}
|
||||
|
||||
Object.keys(allApps).forEach(function (appName) {
|
||||
allAppsUnencrypted[appName] = allApps[appName]
|
||||
@@ -859,7 +859,7 @@ class AppsDataStore {
|
||||
return
|
||||
}
|
||||
|
||||
if (!!self.data.get(`${APP_DEFINITIONS}.${appName}`)) {
|
||||
if (self.data.get(`${APP_DEFINITIONS}.${appName}`)) {
|
||||
reject(
|
||||
ApiStatusCodes.createError(
|
||||
ApiStatusCodes.STATUS_ERROR_ALREADY_EXIST,
|
||||
|
||||
@@ -1318,7 +1318,7 @@ class DockerApi {
|
||||
for (let idx = 0; idx < volumes.length; idx++) {
|
||||
const v = volumes[idx]
|
||||
|
||||
if (!!v.hostPath) {
|
||||
if (v.hostPath) {
|
||||
mts.push({
|
||||
Source: v.hostPath,
|
||||
Target: v.containerPath,
|
||||
@@ -1326,7 +1326,7 @@ class DockerApi {
|
||||
ReadOnly: false,
|
||||
Consistency: 'default',
|
||||
})
|
||||
} else if (!!v.volumeName) {
|
||||
} else if (v.volumeName) {
|
||||
// named volumes are created here:
|
||||
// /var/lib/docker/volumes/YOUR_VOLUME_NAME/_data
|
||||
mts.push({
|
||||
@@ -1420,7 +1420,7 @@ class DockerApi {
|
||||
updatedData.UpdateConfig.Order = 'stop-first'
|
||||
break
|
||||
default:
|
||||
let neverHappens: never = updateOrder
|
||||
const neverHappens: never = updateOrder
|
||||
throw new Error(
|
||||
`Unknown update order! ${updateOrder}${neverHappens}`
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ import Utils from '../../utils/Utils'
|
||||
const router = express.Router()
|
||||
|
||||
router.get('/', function (req, res, next) {
|
||||
let downloadToken = req.query.downloadToken as string
|
||||
let namespace = req.query.namespace as string
|
||||
const downloadToken = req.query.downloadToken as string
|
||||
const namespace = req.query.namespace as string
|
||||
|
||||
Promise.resolve() //
|
||||
.then(function () {
|
||||
|
||||
@@ -12,10 +12,10 @@ const router = express.Router()
|
||||
const failedLoginCircularTimestamps = new CircularQueue<number>(5)
|
||||
|
||||
router.post('/', function (req, res, next) {
|
||||
let password = req.body.password || ''
|
||||
const password = req.body.password || ''
|
||||
|
||||
if (!password) {
|
||||
let response = new BaseApi(
|
||||
const response = new BaseApi(
|
||||
ApiStatusCodes.STATUS_ERROR_GENERIC,
|
||||
'password is empty.'
|
||||
)
|
||||
@@ -59,7 +59,7 @@ router.post('/', function (req, res, next) {
|
||||
})
|
||||
.then(function (cookieAuth) {
|
||||
res.cookie(CaptainConstants.headerCookieAuth, cookieAuth)
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Login succeeded'
|
||||
)
|
||||
|
||||
@@ -28,7 +28,7 @@ router.use(function (req, res, next) {
|
||||
const user = InjectionExtractor.extractUserFromInjected(res).user
|
||||
|
||||
if (!user) {
|
||||
let response = new BaseApi(
|
||||
const response = new BaseApi(
|
||||
ApiStatusCodes.STATUS_ERROR_NOT_AUTHORIZED,
|
||||
'The request is not authorized.'
|
||||
)
|
||||
@@ -37,7 +37,7 @@ router.use(function (req, res, next) {
|
||||
}
|
||||
|
||||
if (!user.initialized) {
|
||||
let response = new BaseApi(
|
||||
const response = new BaseApi(
|
||||
ApiStatusCodes.STATUS_ERROR_USER_NOT_INITIALIZED,
|
||||
'User data is being loaded... Please wait...'
|
||||
)
|
||||
@@ -48,7 +48,7 @@ router.use(function (req, res, next) {
|
||||
const namespace = user.namespace
|
||||
|
||||
if (!namespace) {
|
||||
let response = new BaseApi(
|
||||
const response = new BaseApi(
|
||||
ApiStatusCodes.STATUS_ERROR_NOT_AUTHORIZED,
|
||||
'Cannot find the namespace attached to this user'
|
||||
)
|
||||
@@ -59,7 +59,7 @@ router.use(function (req, res, next) {
|
||||
// All requests except GET might be making changes to some stuff that are not designed for an asynchronous process
|
||||
// I'm being extra cautious. But removal of this lock mechanism requires testing and consideration of edge cases.
|
||||
if (Utils.isNotGetRequest(req)) {
|
||||
if (!!EnvVars.DEMO_MODE_ADMIN_IP) {
|
||||
if (EnvVars.DEMO_MODE_ADMIN_IP) {
|
||||
const realIp = `${req.headers['x-real-ip']}`
|
||||
const forwardedIp = `${req.headers['x-forwarded-for']}`
|
||||
if (
|
||||
@@ -68,7 +68,7 @@ router.use(function (req, res, next) {
|
||||
realIp !== forwardedIp ||
|
||||
EnvVars.DEMO_MODE_ADMIN_IP !== realIp
|
||||
) {
|
||||
let response = new BaseApi(
|
||||
const response = new BaseApi(
|
||||
ApiStatusCodes.STATUS_ERROR_GENERIC,
|
||||
'Demo mode is only for viewing purposes.'
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ const upload = multer({
|
||||
})
|
||||
|
||||
router.get('/:appName/logs', function (req, res, next) {
|
||||
let appName = req.params.appName
|
||||
const appName = req.params.appName
|
||||
const serviceManager =
|
||||
InjectionExtractor.extractUserFromInjected(res).user.serviceManager
|
||||
|
||||
@@ -25,7 +25,7 @@ router.get('/:appName/logs', function (req, res, next) {
|
||||
)
|
||||
})
|
||||
.then(function (logs) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'App runtime logs are retrieved'
|
||||
)
|
||||
@@ -36,7 +36,7 @@ router.get('/:appName/logs', function (req, res, next) {
|
||||
})
|
||||
|
||||
router.get('/:appName/', function (req, res, next) {
|
||||
let appName = req.params.appName
|
||||
const appName = req.params.appName
|
||||
const serviceManager =
|
||||
InjectionExtractor.extractUserFromInjected(res).user.serviceManager
|
||||
|
||||
@@ -45,7 +45,7 @@ router.get('/:appName/', function (req, res, next) {
|
||||
return serviceManager.getBuildStatus(appName)
|
||||
})
|
||||
.then(function (data) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'App build status retrieved'
|
||||
)
|
||||
@@ -58,7 +58,7 @@ router.get('/:appName/', function (req, res, next) {
|
||||
router.post('/:appName/', function (req, res, next) {
|
||||
const dataStore =
|
||||
InjectionExtractor.extractUserFromInjected(res).user.dataStore
|
||||
let appName = req.params.appName
|
||||
const appName = req.params.appName
|
||||
|
||||
dataStore
|
||||
.getAppsDataStore()
|
||||
@@ -82,7 +82,7 @@ router.post(
|
||||
const captainDefinitionContent =
|
||||
(req.body.captainDefinitionContent || '') + ''
|
||||
const gitHash = (req.body.gitHash || '') + ''
|
||||
let tarballSourceFilePath: string = !!req.file ? req.file.path : ''
|
||||
const tarballSourceFilePath: string = req.file ? req.file.path : ''
|
||||
|
||||
if (!!tarballSourceFilePath === !!captainDefinitionContent) {
|
||||
res.send(
|
||||
@@ -97,13 +97,13 @@ router.post(
|
||||
Promise.resolve().then(function () {
|
||||
const promiseToDeployNewVer =
|
||||
serviceManager.scheduleDeployNewVersion(appName, {
|
||||
uploadedTarPathSource: !!tarballSourceFilePath
|
||||
uploadedTarPathSource: tarballSourceFilePath
|
||||
? {
|
||||
uploadedTarPath: tarballSourceFilePath,
|
||||
gitHash,
|
||||
}
|
||||
: undefined,
|
||||
captainDefinitionContentSource: !!captainDefinitionContent
|
||||
captainDefinitionContentSource: captainDefinitionContent
|
||||
? {
|
||||
captainDefinitionContent,
|
||||
gitHash,
|
||||
|
||||
@@ -23,11 +23,11 @@ router.get('/unusedImages', function (req, res, next) {
|
||||
|
||||
Promise.resolve()
|
||||
.then(function () {
|
||||
let mostRecentLimit = Number(req.query.mostRecentLimit || '0')
|
||||
const mostRecentLimit = Number(req.query.mostRecentLimit || '0')
|
||||
return serviceManager.getUnusedImages(mostRecentLimit)
|
||||
})
|
||||
.then(function (unusedImages) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Unused images retrieved.'
|
||||
)
|
||||
@@ -43,14 +43,14 @@ router.get('/unusedImages', function (req, res, next) {
|
||||
router.post('/deleteImages', function (req, res, next) {
|
||||
const serviceManager =
|
||||
InjectionExtractor.extractUserFromInjected(res).user.serviceManager
|
||||
let imageIds = req.body.imageIds || []
|
||||
const imageIds = req.body.imageIds || []
|
||||
|
||||
Promise.resolve()
|
||||
.then(function () {
|
||||
return serviceManager.deleteImages(imageIds)
|
||||
})
|
||||
.then(function () {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Images Deleted.'
|
||||
)
|
||||
@@ -65,16 +65,16 @@ router.get('/', function (req, res, next) {
|
||||
InjectionExtractor.extractUserFromInjected(res).user.dataStore
|
||||
const serviceManager =
|
||||
InjectionExtractor.extractUserFromInjected(res).user.serviceManager
|
||||
let appsArray: IAppDef[] = []
|
||||
const appsArray: IAppDef[] = []
|
||||
|
||||
dataStore
|
||||
.getAppsDataStore()
|
||||
.getAppDefinitions()
|
||||
.then(function (apps) {
|
||||
let promises: Promise<void>[] = []
|
||||
const promises: Promise<void>[] = []
|
||||
|
||||
Object.keys(apps).forEach(function (key, index) {
|
||||
let app = apps[key]
|
||||
const app = apps[key]
|
||||
app.appName = key
|
||||
app.isAppBuilding = serviceManager.isAppBuilding(key)
|
||||
app.appPushWebhook = app.appPushWebhook || undefined
|
||||
@@ -87,7 +87,7 @@ router.get('/', function (req, res, next) {
|
||||
return dataStore.getDefaultAppNginxConfig()
|
||||
})
|
||||
.then(function (defaultNginxConfig) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'App definitions are retrieved.'
|
||||
)
|
||||
@@ -113,7 +113,7 @@ router.post('/enablebasedomainssl/', function (req, res, next) {
|
||||
return serviceManager.enableSslForApp(appName)
|
||||
})
|
||||
.then(function () {
|
||||
let msg = `General SSL is enabled for: ${appName}`
|
||||
const msg = `General SSL is enabled for: ${appName}`
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
@@ -124,8 +124,8 @@ router.post('/customdomain/', function (req, res, next) {
|
||||
const serviceManager =
|
||||
InjectionExtractor.extractUserFromInjected(res).user.serviceManager
|
||||
|
||||
let appName = req.body.appName
|
||||
let customDomain = (req.body.customDomain || '').toLowerCase()
|
||||
const appName = req.body.appName
|
||||
const customDomain = (req.body.customDomain || '').toLowerCase()
|
||||
|
||||
// verify customdomain.com going through the default NGINX
|
||||
// Add customdomain.com to app in Data Store
|
||||
@@ -135,7 +135,7 @@ router.post('/customdomain/', function (req, res, next) {
|
||||
return serviceManager.addCustomDomain(appName, customDomain)
|
||||
})
|
||||
.then(function () {
|
||||
let msg = `Custom domain is enabled for: ${appName} at ${customDomain}`
|
||||
const msg = `Custom domain is enabled for: ${appName} at ${customDomain}`
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
@@ -146,15 +146,15 @@ router.post('/removecustomdomain/', function (req, res, next) {
|
||||
const serviceManager =
|
||||
InjectionExtractor.extractUserFromInjected(res).user.serviceManager
|
||||
|
||||
let appName = req.body.appName
|
||||
let customDomain = (req.body.customDomain || '').toLowerCase()
|
||||
const appName = req.body.appName
|
||||
const customDomain = (req.body.customDomain || '').toLowerCase()
|
||||
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
return serviceManager.removeCustomDomain(appName, customDomain)
|
||||
})
|
||||
.then(function () {
|
||||
let msg = `Custom domain is removed for: ${appName} at ${customDomain}`
|
||||
const msg = `Custom domain is removed for: ${appName} at ${customDomain}`
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
@@ -165,8 +165,8 @@ router.post('/enablecustomdomainssl/', function (req, res, next) {
|
||||
const serviceManager =
|
||||
InjectionExtractor.extractUserFromInjected(res).user.serviceManager
|
||||
|
||||
let appName = req.body.appName
|
||||
let customDomain = (req.body.customDomain || '').toLowerCase()
|
||||
const appName = req.body.appName
|
||||
const customDomain = (req.body.customDomain || '').toLowerCase()
|
||||
|
||||
// Check if customdomain is already associated with app. If not, error out.
|
||||
// Verify customdomain.com is served from /customdomain.com/
|
||||
@@ -176,7 +176,7 @@ router.post('/enablecustomdomainssl/', function (req, res, next) {
|
||||
return serviceManager.enableCustomDomainSsl(appName, customDomain)
|
||||
})
|
||||
.then(function () {
|
||||
let msg = `Custom domain SSL is enabled for: ${appName} at ${customDomain} `
|
||||
const msg = `Custom domain SSL is enabled for: ${appName} at ${customDomain} `
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
@@ -248,8 +248,8 @@ router.post('/delete/', function (req, res, next) {
|
||||
const serviceManager =
|
||||
InjectionExtractor.extractUserFromInjected(res).user.serviceManager
|
||||
|
||||
let appName = req.body.appName
|
||||
let volumes = req.body.volumes || []
|
||||
const appName = req.body.appName
|
||||
const volumes = req.body.volumes || []
|
||||
|
||||
Logger.d(`Deleting app started: ${appName}`)
|
||||
|
||||
@@ -288,8 +288,8 @@ router.post('/rename/', function (req, res, next) {
|
||||
const serviceManager =
|
||||
InjectionExtractor.extractUserFromInjected(res).user.serviceManager
|
||||
|
||||
let oldAppName = req.body.oldAppName + ''
|
||||
let newAppName = req.body.newAppName + ''
|
||||
const oldAppName = req.body.oldAppName + ''
|
||||
const newAppName = req.body.newAppName + ''
|
||||
|
||||
Logger.d(`Renaming app started: From ${oldAppName} To ${newAppName} `)
|
||||
|
||||
@@ -310,29 +310,29 @@ router.post('/update/', function (req, res, next) {
|
||||
const serviceManager =
|
||||
InjectionExtractor.extractUserFromInjected(res).user.serviceManager
|
||||
|
||||
let appName = req.body.appName
|
||||
let nodeId = req.body.nodeId
|
||||
let captainDefinitionRelativeFilePath =
|
||||
const appName = req.body.appName
|
||||
const nodeId = req.body.nodeId
|
||||
const captainDefinitionRelativeFilePath =
|
||||
req.body.captainDefinitionRelativeFilePath
|
||||
let notExposeAsWebApp = req.body.notExposeAsWebApp
|
||||
let customNginxConfig = req.body.customNginxConfig
|
||||
let forceSsl = !!req.body.forceSsl
|
||||
let websocketSupport = !!req.body.websocketSupport
|
||||
let repoInfo = !!req.body.appPushWebhook
|
||||
const notExposeAsWebApp = req.body.notExposeAsWebApp
|
||||
const customNginxConfig = req.body.customNginxConfig
|
||||
const forceSsl = !!req.body.forceSsl
|
||||
const websocketSupport = !!req.body.websocketSupport
|
||||
const repoInfo = req.body.appPushWebhook
|
||||
? req.body.appPushWebhook.repoInfo || {}
|
||||
: {}
|
||||
let envVars = req.body.envVars || []
|
||||
let volumes = req.body.volumes || []
|
||||
let ports = req.body.ports || []
|
||||
let instanceCount = req.body.instanceCount || '0'
|
||||
let preDeployFunction = req.body.preDeployFunction || ''
|
||||
let serviceUpdateOverride = req.body.serviceUpdateOverride || ''
|
||||
let containerHttpPort = Number(req.body.containerHttpPort) || 80
|
||||
let httpAuth = req.body.httpAuth
|
||||
const envVars = req.body.envVars || []
|
||||
const volumes = req.body.volumes || []
|
||||
const ports = req.body.ports || []
|
||||
const instanceCount = req.body.instanceCount || '0'
|
||||
const preDeployFunction = req.body.preDeployFunction || ''
|
||||
const serviceUpdateOverride = req.body.serviceUpdateOverride || ''
|
||||
const containerHttpPort = Number(req.body.containerHttpPort) || 80
|
||||
const httpAuth = req.body.httpAuth
|
||||
let appDeployTokenConfig = req.body.appDeployTokenConfig as
|
||||
| AppDeployTokenConfig
|
||||
| undefined
|
||||
let description = req.body.description || ''
|
||||
const description = req.body.description || ''
|
||||
|
||||
if (!appDeployTokenConfig) {
|
||||
appDeployTokenConfig = { enabled: false }
|
||||
|
||||
@@ -16,27 +16,27 @@ function getPushedBranches(req: express.Request) {
|
||||
|
||||
// find which branch is pushed
|
||||
// Add it in pushedBranches
|
||||
let isGithub = req.header('X-GitHub-Event') === 'push'
|
||||
let isBitbucket =
|
||||
const isGithub = req.header('X-GitHub-Event') === 'push'
|
||||
const isBitbucket =
|
||||
req.header('X-Event-Key') === 'repo:push' &&
|
||||
req.header('X-Request-UUID') &&
|
||||
req.header('X-Hook-UUID')
|
||||
let isGitlab = req.header('X-Gitlab-Event') === 'Push Hook'
|
||||
const isGitlab = req.header('X-Gitlab-Event') === 'Push Hook'
|
||||
|
||||
if (isGithub) {
|
||||
let refPayloadByFormEncoded = req.body.payload
|
||||
const refPayloadByFormEncoded = req.body.payload
|
||||
let bodyJson = req.body
|
||||
if (refPayloadByFormEncoded) {
|
||||
bodyJson = JSON.parse(refPayloadByFormEncoded)
|
||||
}
|
||||
let ref = bodyJson.ref // "refs/heads/somebranch"
|
||||
const ref = bodyJson.ref // "refs/heads/somebranch"
|
||||
pushedBranches.push(ref.substring(11, ref.length))
|
||||
} else if (isBitbucket) {
|
||||
for (let i = 0; i < req.body.push.changes.length; i++) {
|
||||
pushedBranches.push(req.body.push.changes[i].new.name)
|
||||
}
|
||||
} else if (isGitlab) {
|
||||
let ref = req.body.ref // "refs/heads/somebranch"
|
||||
const ref = req.body.ref // "refs/heads/somebranch"
|
||||
pushedBranches.push(ref.substring(11, ref.length))
|
||||
}
|
||||
return pushedBranches
|
||||
|
||||
@@ -61,7 +61,7 @@ router.post('/repositories/insert', function (req, res, next) {
|
||||
return dataStore.insertOneClickBaseUrl(apiBaseUrl)
|
||||
})
|
||||
.then(function () {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
`One Click apps repository URL is saved: ${apiBaseUrl}`
|
||||
)
|
||||
@@ -93,7 +93,7 @@ router.post('/repositories/delete', function (req, res, next) {
|
||||
return dataStore.deleteOneClickBaseUrl(apiBaseUrl)
|
||||
})
|
||||
.then(function () {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
`One Click apps repository URL is deleted ${apiBaseUrl}`
|
||||
)
|
||||
@@ -111,7 +111,7 @@ router.get('/repositories/', function (req, res, next) {
|
||||
return dataStore.getAllOneClickBaseUrls()
|
||||
})
|
||||
.then(function (urls) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'One click repositories are retrieved '
|
||||
)
|
||||
@@ -178,7 +178,7 @@ router.get('/template/list', function (req, res, next) {
|
||||
return allApps
|
||||
})
|
||||
.then(function (allApps) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'All one click apps are retrieved'
|
||||
)
|
||||
@@ -215,7 +215,7 @@ router.get('/template/app', function (req, res, next) {
|
||||
})
|
||||
})
|
||||
.then(function (appTemplate) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'App template is retrieved'
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ router.get('/', function (req, res, next) {
|
||||
return registryHelper.getDefaultPushRegistryId()
|
||||
})
|
||||
.then(function (defaultPush) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'All registries retrieved'
|
||||
)
|
||||
@@ -36,10 +36,10 @@ router.get('/', function (req, res, next) {
|
||||
})
|
||||
|
||||
router.post('/insert/', function (req, res, next) {
|
||||
let registryUser = req.body.registryUser + ''
|
||||
let registryPassword = req.body.registryPassword + ''
|
||||
let registryDomain = req.body.registryDomain + ''
|
||||
let registryImagePrefix = req.body.registryImagePrefix + ''
|
||||
const registryUser = req.body.registryUser + ''
|
||||
const registryPassword = req.body.registryPassword + ''
|
||||
const registryDomain = req.body.registryDomain + ''
|
||||
const registryImagePrefix = req.body.registryImagePrefix + ''
|
||||
|
||||
const registryHelper =
|
||||
InjectionExtractor.extractUserFromInjected(
|
||||
@@ -57,7 +57,7 @@ router.post('/insert/', function (req, res, next) {
|
||||
)
|
||||
})
|
||||
.then(function () {
|
||||
let msg = 'Registry is added.'
|
||||
const msg = 'Registry is added.'
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
@@ -66,11 +66,11 @@ router.post('/insert/', function (req, res, next) {
|
||||
|
||||
// ERRORS if it's local
|
||||
router.post('/update/', function (req, res, next) {
|
||||
let registryId = req.body.id + ''
|
||||
let registryUser = req.body.registryUser + ''
|
||||
let registryPassword = req.body.registryPassword + ''
|
||||
let registryDomain = req.body.registryDomain + ''
|
||||
let registryImagePrefix = req.body.registryImagePrefix + ''
|
||||
const registryId = req.body.id + ''
|
||||
const registryUser = req.body.registryUser + ''
|
||||
const registryPassword = req.body.registryPassword + ''
|
||||
const registryDomain = req.body.registryDomain + ''
|
||||
const registryImagePrefix = req.body.registryImagePrefix + ''
|
||||
|
||||
const registryHelper =
|
||||
InjectionExtractor.extractUserFromInjected(
|
||||
@@ -88,7 +88,7 @@ router.post('/update/', function (req, res, next) {
|
||||
)
|
||||
})
|
||||
.then(function () {
|
||||
let msg = 'Registry is updated.'
|
||||
const msg = 'Registry is updated.'
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
@@ -97,7 +97,7 @@ router.post('/update/', function (req, res, next) {
|
||||
|
||||
// ERRORS if default push is this OR if it's local
|
||||
router.post('/delete/', function (req, res, next) {
|
||||
let registryId = req.body.registryId + ''
|
||||
const registryId = req.body.registryId + ''
|
||||
const registryHelper =
|
||||
InjectionExtractor.extractUserFromInjected(
|
||||
res
|
||||
@@ -108,7 +108,7 @@ router.post('/delete/', function (req, res, next) {
|
||||
return registryHelper.deleteRegistry(registryId, false)
|
||||
})
|
||||
.then(function () {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Registry deleted'
|
||||
)
|
||||
@@ -118,7 +118,7 @@ router.post('/delete/', function (req, res, next) {
|
||||
})
|
||||
|
||||
router.post('/setpush/', function (req, res, next) {
|
||||
let registryId = req.body.registryId + ''
|
||||
const registryId = req.body.registryId + ''
|
||||
const registryHelper =
|
||||
InjectionExtractor.extractUserFromInjected(
|
||||
res
|
||||
@@ -129,7 +129,7 @@ router.post('/setpush/', function (req, res, next) {
|
||||
return registryHelper.setDefaultPushRegistry(registryId)
|
||||
})
|
||||
.then(function () {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Push Registry changed'
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@ router.post('/createbackup/', function (req, res, next) {
|
||||
})
|
||||
|
||||
router.post('/changerootdomain/', function (req, res, next) {
|
||||
let requestedCustomDomain = Utils.removeHttpHttps(
|
||||
const requestedCustomDomain = Utils.removeHttpHttps(
|
||||
(req.body.rootDomain || '').toLowerCase()
|
||||
)
|
||||
|
||||
@@ -101,7 +101,7 @@ router.post('/enablessl/', function (req, res, next) {
|
||||
})
|
||||
|
||||
router.post('/forcessl/', function (req, res, next) {
|
||||
let isEnabled = !!req.body.isEnabled
|
||||
const isEnabled = !!req.body.isEnabled
|
||||
|
||||
CaptainManager.get()
|
||||
.forceSsl(isEnabled)
|
||||
@@ -136,7 +136,7 @@ router.get('/info/', function (req, res, next) {
|
||||
}
|
||||
})
|
||||
.then(function (data) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Captain info retrieved'
|
||||
)
|
||||
@@ -152,7 +152,7 @@ router.get('/loadbalancerinfo/', function (req, res, next) {
|
||||
return CaptainManager.get().getLoadBalanceManager().getInfo()
|
||||
})
|
||||
.then(function (data) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Load Balancer info retrieved'
|
||||
)
|
||||
@@ -168,7 +168,7 @@ router.get('/versionInfo/', function (req, res, next) {
|
||||
return VersionManager.get().getCaptainImageTags()
|
||||
})
|
||||
.then(function (data) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Version Info Retrieved'
|
||||
)
|
||||
@@ -179,14 +179,14 @@ router.get('/versionInfo/', function (req, res, next) {
|
||||
})
|
||||
|
||||
router.post('/versionInfo/', function (req, res, next) {
|
||||
let latestVersion = req.body.latestVersion
|
||||
const latestVersion = req.body.latestVersion
|
||||
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
return VersionManager.get().updateCaptain(latestVersion)
|
||||
})
|
||||
.then(function () {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Captain update process has started...'
|
||||
)
|
||||
@@ -209,7 +209,7 @@ router.get('/netdata/', function (req, res, next) {
|
||||
}.${dataStore.getRootDomain()}${
|
||||
CaptainConstants.netDataRelativePath
|
||||
}`
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Netdata info retrieved'
|
||||
)
|
||||
@@ -220,7 +220,7 @@ router.get('/netdata/', function (req, res, next) {
|
||||
})
|
||||
|
||||
router.post('/netdata/', function (req, res, next) {
|
||||
let netDataInfo = req.body.netDataInfo
|
||||
const netDataInfo = req.body.netDataInfo
|
||||
netDataInfo.netDataUrl = undefined // Frontend app returns this value, but we really don't wanna save this.
|
||||
// root address is subject to change.
|
||||
|
||||
@@ -229,7 +229,7 @@ router.post('/netdata/', function (req, res, next) {
|
||||
return CaptainManager.get().updateNetDataInfo(netDataInfo)
|
||||
})
|
||||
.then(function () {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Netdata info is updated'
|
||||
)
|
||||
@@ -244,7 +244,7 @@ router.get('/nginxconfig/', function (req, res, next) {
|
||||
return CaptainManager.get().getNginxConfig()
|
||||
})
|
||||
.then(function (data) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Nginx config retrieved'
|
||||
)
|
||||
@@ -255,8 +255,8 @@ router.get('/nginxconfig/', function (req, res, next) {
|
||||
})
|
||||
|
||||
router.post('/nginxconfig/', function (req, res, next) {
|
||||
let baseConfigCustomValue = req.body.baseConfig.customValue
|
||||
let captainConfigCustomValue = req.body.captainConfig.customValue
|
||||
const baseConfigCustomValue = req.body.baseConfig.customValue
|
||||
const captainConfigCustomValue = req.body.captainConfig.customValue
|
||||
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
@@ -266,7 +266,7 @@ router.post('/nginxconfig/', function (req, res, next) {
|
||||
)
|
||||
})
|
||||
.then(function () {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Nginx config is updated'
|
||||
)
|
||||
@@ -281,7 +281,7 @@ router.get('/nodes/', function (req, res, next) {
|
||||
return CaptainManager.get().getNodesInfo()
|
||||
})
|
||||
.then(function (data) {
|
||||
let baseApi = new BaseApi(
|
||||
const baseApi = new BaseApi(
|
||||
ApiStatusCodes.STATUS_OK,
|
||||
'Node info retrieved'
|
||||
)
|
||||
@@ -315,11 +315,11 @@ router.post('/nodes/', function (req, res, next) {
|
||||
return
|
||||
}
|
||||
|
||||
let privateKey = req.body.privateKey
|
||||
let remoteNodeIpAddress = req.body.remoteNodeIpAddress
|
||||
let captainIpAddress = req.body.captainIpAddress
|
||||
let sshPort = parseInt(req.body.sshPort) || 22
|
||||
let sshUser = (req.body.sshUser || 'root').trim()
|
||||
const privateKey = req.body.privateKey
|
||||
const remoteNodeIpAddress = req.body.remoteNodeIpAddress
|
||||
const captainIpAddress = req.body.captainIpAddress
|
||||
const sshPort = parseInt(req.body.sshPort) || 22
|
||||
const sshUser = (req.body.sshUser || 'root').trim()
|
||||
|
||||
if (!captainIpAddress || !remoteNodeIpAddress || !privateKey) {
|
||||
res.send(
|
||||
@@ -355,7 +355,7 @@ router.post('/nodes/', function (req, res, next) {
|
||||
)
|
||||
})
|
||||
.then(function () {
|
||||
let msg = 'Docker node is successfully joined.'
|
||||
const msg = 'Docker node is successfully joined.'
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
|
||||
@@ -41,8 +41,8 @@ router.post('/enableregistry/', function (req, res, next) {
|
||||
)
|
||||
}
|
||||
}
|
||||
let user = CaptainConstants.captainRegistryUsername
|
||||
let domain = captainManager
|
||||
const user = CaptainConstants.captainRegistryUsername
|
||||
const domain = captainManager
|
||||
.getDockerRegistry()
|
||||
.getLocalRegistryDomainAndPort()
|
||||
|
||||
@@ -55,7 +55,7 @@ router.post('/enableregistry/', function (req, res, next) {
|
||||
)
|
||||
})
|
||||
.then(function () {
|
||||
let msg = 'Local registry is created.'
|
||||
const msg = 'Local registry is created.'
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
@@ -89,7 +89,7 @@ router.post('/disableregistry/', function (req, res, next) {
|
||||
return captainManager.getDockerRegistry().ensureServiceRemoved()
|
||||
})
|
||||
.then(function () {
|
||||
let msg = 'Local registry is removed.'
|
||||
const msg = 'Local registry is removed.'
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
|
||||
@@ -42,7 +42,7 @@ class DockerRegistryHelper {
|
||||
return self.getDefaultPushRegistryId()
|
||||
})
|
||||
.then(function (defaultRegId) {
|
||||
let ret: IRegistryInfo | undefined = undefined
|
||||
const ret: IRegistryInfo | undefined = undefined
|
||||
for (let idx = 0; idx < allRegistries.length; idx++) {
|
||||
const element = allRegistries[idx]
|
||||
if (defaultRegId && element.id === defaultRegId) {
|
||||
@@ -166,7 +166,7 @@ class DockerRegistryHelper {
|
||||
return self.getAllRegistries()
|
||||
})
|
||||
.then(function (regs) {
|
||||
let registryConfig: DockerRegistryConfig = {}
|
||||
const registryConfig: DockerRegistryConfig = {}
|
||||
|
||||
for (let index = 0; index < regs.length; index++) {
|
||||
const element = regs[index]
|
||||
|
||||
@@ -397,10 +397,10 @@ export default class ImageMaker {
|
||||
const hasDockerfileLines =
|
||||
data.dockerfileLines && data.dockerfileLines.length > 0
|
||||
|
||||
let numberOfProperties =
|
||||
(!!data.templateId ? 1 : 0) +
|
||||
(!!data.imageName ? 1 : 0) +
|
||||
(!!data.dockerfilePath ? 1 : 0) +
|
||||
const numberOfProperties =
|
||||
(data.templateId ? 1 : 0) +
|
||||
(data.imageName ? 1 : 0) +
|
||||
(data.dockerfilePath ? 1 : 0) +
|
||||
(hasDockerfileLines ? 1 : 0)
|
||||
|
||||
if (numberOfProperties !== 1) {
|
||||
@@ -420,7 +420,7 @@ export default class ImageMaker {
|
||||
) {
|
||||
return Promise.resolve() //
|
||||
.then(function () {
|
||||
let data = captainDefinition
|
||||
const data = captainDefinition
|
||||
if (data.templateId) {
|
||||
return TemplateHelper.get().getDockerfileContentFromTemplateTag(
|
||||
data.templateId
|
||||
|
||||
@@ -91,7 +91,7 @@ class ServiceManager {
|
||||
scheduleDeployNewVersion(appName: string, source: IImageSource) {
|
||||
const self = this
|
||||
|
||||
let activeBuildAppName = self.isAnyBuildRunning()
|
||||
const activeBuildAppName = self.isAnyBuildRunning()
|
||||
this.activeOrScheduledBuilds[appName] = true
|
||||
|
||||
self.buildLogsManager.getAppBuildLogs(appName).clear()
|
||||
@@ -128,13 +128,13 @@ class ServiceManager {
|
||||
`An active build (${activeBuildAppName}) is in progress. This build is queued...`
|
||||
)
|
||||
|
||||
let promiseToSave: QueuedPromise = {
|
||||
const promiseToSave: QueuedPromise = {
|
||||
resolve: undefined,
|
||||
reject: undefined,
|
||||
promise: undefined,
|
||||
}
|
||||
|
||||
let promise = new Promise(function (resolve, reject) {
|
||||
const promise = new Promise(function (resolve, reject) {
|
||||
promiseToSave.resolve = resolve
|
||||
promiseToSave.reject = reject
|
||||
})
|
||||
@@ -218,7 +218,7 @@ class ServiceManager {
|
||||
self.activeOrScheduledBuilds[appName] = false
|
||||
|
||||
Promise.resolve().then(function () {
|
||||
let newBuild = self.queuedBuilds.shift()
|
||||
const newBuild = self.queuedBuilds.shift()
|
||||
if (newBuild)
|
||||
self.startDeployingNewVersion(newBuild.appName, newBuild.source)
|
||||
})
|
||||
@@ -748,7 +748,7 @@ class ServiceManager {
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
serviceUpdateOverride = !!serviceUpdateOverride
|
||||
serviceUpdateOverride = serviceUpdateOverride
|
||||
? `${serviceUpdateOverride}`.trim()
|
||||
: ''
|
||||
if (!serviceUpdateOverride) {
|
||||
@@ -808,7 +808,7 @@ class ServiceManager {
|
||||
const activeBuilds = this.activeOrScheduledBuilds
|
||||
|
||||
for (const appName in activeBuilds) {
|
||||
if (!!activeBuilds[appName]) {
|
||||
if (activeBuilds[appName]) {
|
||||
return appName
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import fs = require('fs-extra')
|
||||
import ApiStatusCodes from '../api/ApiStatusCodes'
|
||||
import { ITemplate } from '../models/OtherTypes'
|
||||
import TemplateHelperVersionPrinter from '../utils/TemplateHelperVersionPrinter'
|
||||
|
||||
class TemplateHelper {
|
||||
private templates: ITemplate[]
|
||||
@@ -42,11 +41,9 @@ class TemplateHelper {
|
||||
this.templates = templates
|
||||
|
||||
// Change to true if you want tags to be printed on screen upon start up (after 40 sec ish)
|
||||
if (false) {
|
||||
new TemplateHelperVersionPrinter().printAvailableImageTagsForReadme(
|
||||
this.templates
|
||||
)
|
||||
}
|
||||
// new TemplateHelperVersionPrinter().printAvailableImageTagsForReadme(
|
||||
// this.templates
|
||||
// )
|
||||
}
|
||||
|
||||
getTemplateFromTemplateName(templateName: string) {
|
||||
|
||||
@@ -334,7 +334,7 @@ export default class BackupManager {
|
||||
|
||||
if (n.newIp === CURRENT_NODE_DONT_CHANGE) return
|
||||
|
||||
if (!!n.newIp) {
|
||||
if (n.newIp) {
|
||||
if (n.newIp === IP_PLACEHOLDER) {
|
||||
Logger.d(
|
||||
'*** MULTI-NODE RESTORATION DETECTED ***'
|
||||
@@ -689,7 +689,7 @@ export default class BackupManager {
|
||||
['./']
|
||||
)
|
||||
.then(function () {
|
||||
let fileSizeInMb = Math.ceil(
|
||||
const fileSizeInMb = Math.ceil(
|
||||
fs.statSync(tarFilePath).size / 1000000
|
||||
)
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ class CaptainManager {
|
||||
)
|
||||
.migrateIfNeeded()
|
||||
.then(function (migrationPerformed) {
|
||||
if (!!migrationPerformed) {
|
||||
if (migrationPerformed) {
|
||||
return self.resetSelf()
|
||||
}
|
||||
})
|
||||
@@ -226,7 +226,7 @@ class CaptainManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (!!localRegistry) {
|
||||
if (localRegistry) {
|
||||
Logger.d('Ensuring Docker Registry is running...')
|
||||
return self.dockerRegistry.ensureDockerRegistryRunningOnThisNode(
|
||||
localRegistry.registryPassword
|
||||
@@ -786,7 +786,7 @@ class CaptainManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (!!localRegistry) {
|
||||
if (localRegistry) {
|
||||
throw ApiStatusCodes.createError(
|
||||
ApiStatusCodes.ILLEGAL_OPERATION,
|
||||
'Delete your self-hosted Docker registry before changing the domain.'
|
||||
|
||||
@@ -78,7 +78,7 @@ class LoadBalancerManager {
|
||||
})
|
||||
self.consumeQueueIfAnyInNginxReloadQueue()
|
||||
}).then(function () {
|
||||
if (!!noReload) return
|
||||
if (noReload) return
|
||||
Logger.d('sendReloadSignal...')
|
||||
return self.dockerApi.sendSingleContainerKillHUP(
|
||||
CaptainConstants.nginxServiceName
|
||||
|
||||
@@ -105,13 +105,13 @@ class VersionManager {
|
||||
}
|
||||
)
|
||||
}).then(function (tagList) {
|
||||
let currentVersion = CaptainConstants.configs.version.split('.')
|
||||
const currentVersion = CaptainConstants.configs.version.split('.')
|
||||
let latestVersion = CaptainConstants.configs.version.split('.')
|
||||
|
||||
let canUpdate = false
|
||||
|
||||
for (let i = 0; i < tagList.length; i++) {
|
||||
let tag = tagList[i].split('.')
|
||||
const tag = tagList[i].split('.')
|
||||
|
||||
if (tag.length !== 3) {
|
||||
continue
|
||||
|
||||
@@ -32,7 +32,7 @@ export default class ApacheMd5 {
|
||||
} else {
|
||||
while (salt.length < 8) {
|
||||
// Random 8 chars.
|
||||
let rchIndex = Math.floor(Math.random() * 64)
|
||||
const rchIndex = Math.floor(Math.random() * 64)
|
||||
salt += itoa64[rchIndex]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ const configs = {
|
||||
captainSubDomain: 'captain',
|
||||
}
|
||||
|
||||
let data = {
|
||||
const data = {
|
||||
configs: configs, // values that can be overridden
|
||||
|
||||
// ******************** Global Constants *********************
|
||||
@@ -170,12 +170,13 @@ let data = {
|
||||
}
|
||||
|
||||
function overrideFromFile(fileName: string) {
|
||||
let overridingValuesConfigs = fs.readJsonSync(fileName, {
|
||||
const overridingValuesConfigs = fs.readJsonSync(fileName, {
|
||||
throws: false,
|
||||
})
|
||||
|
||||
if (!!overridingValuesConfigs) {
|
||||
for (let prop in overridingValuesConfigs) {
|
||||
if (overridingValuesConfigs) {
|
||||
for (const prop in overridingValuesConfigs) {
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (!overridingValuesConfigs.hasOwnProperty(prop)) {
|
||||
continue
|
||||
}
|
||||
@@ -192,7 +193,7 @@ overrideFromFile(CONSTANT_FILE_OVERRIDE_BUILD)
|
||||
overrideFromFile(CONSTANT_FILE_OVERRIDE_USER)
|
||||
|
||||
if (data.isDebug) {
|
||||
let devDirectoryOnLocalMachine = fs
|
||||
const devDirectoryOnLocalMachine = fs
|
||||
.readFileSync(__dirname + '/../../currentdirectory')
|
||||
.toString()
|
||||
.trim()
|
||||
|
||||
@@ -20,9 +20,9 @@ function checkSystemReq() {
|
||||
console.log(' ')
|
||||
console.log(' >>> Checking System Compatibility <<<')
|
||||
|
||||
let ver = output.Version.split('.')
|
||||
let maj = Number(ver[0])
|
||||
let min = Number(ver[1])
|
||||
const ver = output.Version.split('.')
|
||||
const maj = Number(ver[0])
|
||||
const min = Number(ver[1])
|
||||
|
||||
let versionOk = false
|
||||
|
||||
@@ -59,7 +59,7 @@ function checkSystemReq() {
|
||||
console.log(' X86 CPU detected.')
|
||||
}
|
||||
|
||||
let totalMemInMb = Math.round(output.MemTotal / 1000.0 / 1000.0)
|
||||
const totalMemInMb = Math.round(output.MemTotal / 1000.0 / 1000.0)
|
||||
|
||||
if (totalMemInMb < 1000) {
|
||||
console.log(
|
||||
@@ -292,14 +292,14 @@ export function install() {
|
||||
return DockerApi.get().getLeaderNodeId()
|
||||
})
|
||||
.then(function (nodeId: string) {
|
||||
let volumeToMount = [
|
||||
const volumeToMount = [
|
||||
{
|
||||
hostPath: CaptainConstants.captainBaseDirectory,
|
||||
containerPath: CaptainConstants.captainBaseDirectory,
|
||||
},
|
||||
]
|
||||
|
||||
let env = [] as IAppEnvVar[]
|
||||
const env = [] as IAppEnvVar[]
|
||||
env.push({
|
||||
key: EnvVar.keys.IS_CAPTAIN_INSTANCE,
|
||||
value: '1',
|
||||
@@ -324,7 +324,7 @@ export function install() {
|
||||
})
|
||||
}
|
||||
|
||||
let ports: IAppPort[] = []
|
||||
const ports: IAppPort[] = []
|
||||
|
||||
let captainNameAndVersion = `${CaptainConstants.configs.publishedNameOnDockerHub}:${CaptainConstants.configs.version}`
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ export default class CaptainEncryptor {
|
||||
encrypt(clearText: string) {
|
||||
const self = this
|
||||
|
||||
let iv = crypto.randomBytes(IV_LENGTH)
|
||||
let key = Buffer.from(self.encryptionKey)
|
||||
let cipher = crypto.createCipheriv(algorithm, key, iv)
|
||||
const iv = crypto.randomBytes(IV_LENGTH)
|
||||
const key = Buffer.from(self.encryptionKey)
|
||||
const cipher = crypto.createCipheriv(algorithm, key, iv)
|
||||
let encrypted = cipher.update(clearText)
|
||||
|
||||
encrypted = Buffer.concat([encrypted, cipher.final()])
|
||||
@@ -44,14 +44,14 @@ export default class CaptainEncryptor {
|
||||
const self = this
|
||||
text = text + ''
|
||||
|
||||
let textParts = text.split(':')
|
||||
let shifted = textParts.shift()
|
||||
const textParts = text.split(':')
|
||||
const shifted = textParts.shift()
|
||||
if (!shifted) throw new Error('text.split failed')
|
||||
|
||||
let iv = Buffer.from(shifted, 'hex')
|
||||
let encryptedText = Buffer.from(textParts.join(':'), 'hex')
|
||||
let key = Buffer.from(self.encryptionKey)
|
||||
let decipher = crypto.createDecipheriv(algorithm, key, iv)
|
||||
const iv = Buffer.from(shifted, 'hex')
|
||||
const encryptedText = Buffer.from(textParts.join(':'), 'hex')
|
||||
const key = Buffer.from(self.encryptionKey)
|
||||
const decipher = crypto.createDecipheriv(algorithm, key, iv)
|
||||
let decrypted = decipher.update(encryptedText)
|
||||
|
||||
decrypted = Buffer.concat([decrypted, decipher.final()])
|
||||
|
||||
@@ -27,7 +27,7 @@ export default class GitHelper {
|
||||
const USER = encodeURIComponent(username)
|
||||
const PASS = encodeURIComponent(pass)
|
||||
|
||||
if (!!sshKey) {
|
||||
if (sshKey) {
|
||||
const SSH_KEY_PATH = path.join(
|
||||
CaptainConstants.captainRootDirectoryTemp,
|
||||
uuid.v4()
|
||||
@@ -85,7 +85,9 @@ export default class GitHelper {
|
||||
return git() //
|
||||
.silent(true) //
|
||||
.raw(['clone', '--recursive', '-b', branch, remote, directory])
|
||||
.then(function () {})
|
||||
.then(function () {
|
||||
//
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class Logger {
|
||||
}
|
||||
|
||||
static e(msgOrError: AnyError) {
|
||||
let err = errorize(msgOrError)
|
||||
const err = errorize(msgOrError)
|
||||
console.error(`${getTime() + err}
|
||||
${err.stack}`)
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ export default class MigrateCaptainDuckDuck {
|
||||
)
|
||||
|
||||
oldVers.forEach((element) => {
|
||||
let thisVersion = Number(
|
||||
const thisVersion = Number(
|
||||
element.version
|
||||
)
|
||||
|
||||
@@ -348,7 +348,9 @@ export default class MigrateCaptainDuckDuck {
|
||||
promises.push(p)
|
||||
})
|
||||
|
||||
return Promise.all(promises).then(function () {})
|
||||
return Promise.all(promises).then(function () {
|
||||
//
|
||||
})
|
||||
})
|
||||
.then(function () {
|
||||
Logger.d(
|
||||
|
||||
@@ -71,6 +71,7 @@ function firstEndsWithSecond(str1: string, str2: string) {
|
||||
|
||||
function isEmpty(obj: any) {
|
||||
for (const key in obj) {
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
return false
|
||||
}
|
||||
|
||||
+3
-3
@@ -51,7 +51,7 @@ export default class Utils {
|
||||
}
|
||||
|
||||
static convertYamlOrJsonToObject(raw: string | undefined) {
|
||||
raw = !!raw ? `${raw}`.trim() : ''
|
||||
raw = raw ? `${raw}`.trim() : ''
|
||||
if (!raw.length) {
|
||||
return undefined
|
||||
}
|
||||
@@ -101,7 +101,7 @@ export default class Utils {
|
||||
}
|
||||
|
||||
static filterInPlace<T>(arr: T[], condition: (value: T) => boolean) {
|
||||
let newArray = arr.filter(condition)
|
||||
const newArray = arr.filter(condition)
|
||||
arr.splice(0, arr.length)
|
||||
newArray.forEach((value) => arr.push(value))
|
||||
}
|
||||
@@ -119,7 +119,7 @@ export default class Utils {
|
||||
promises: (() => Promise<void>)[],
|
||||
curr?: number
|
||||
): Promise<void> {
|
||||
let currCorrected = curr ? curr : 0
|
||||
const currCorrected = curr ? curr : 0
|
||||
if (promises.length > currCorrected) {
|
||||
return promises[currCorrected]().then(function () {
|
||||
return Utils.runPromises(promises, currCorrected + 1)
|
||||
|
||||
@@ -4,7 +4,7 @@ test('Testing Encryptor 1', () => {
|
||||
const encryptor = new CaptainEncryptor(
|
||||
'8h9hasfasaaaaaaaaaaaaaa75h7553245235423452345235235235254h75h38'
|
||||
)
|
||||
let valueToBeEncrypter = 'qq'
|
||||
const valueToBeEncrypter = 'qq'
|
||||
expect(encryptor.decrypt(encryptor.encrypt(valueToBeEncrypter))).toBe(
|
||||
valueToBeEncrypter
|
||||
)
|
||||
@@ -14,7 +14,7 @@ test('Testing Encryptor 2', () => {
|
||||
const encryptor = new CaptainEncryptor(
|
||||
'8h9hasfasaaaaaaaaaaaaaa75h7553245235423452345235235235254h75h38'
|
||||
)
|
||||
let valueToBeEncrypter = 'q290852f98nb80nv8m8m bn83vn@ 8098m%#@%$5$@#52q'
|
||||
const valueToBeEncrypter = 'q290852f98nb80nv8m8m bn83vn@ 8098m%#@%$5$@#52q'
|
||||
expect(encryptor.decrypt(encryptor.encrypt(valueToBeEncrypter))).toBe(
|
||||
valueToBeEncrypter
|
||||
)
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"rules": {
|
||||
"class-name": true,
|
||||
"comment-format": [true, "check-space"],
|
||||
"indent": [true, "spaces"],
|
||||
"one-line": [true, "check-open-brace", "check-whitespace"],
|
||||
"no-var-keyword": true,
|
||||
"quotemark": [true, "single", "avoid-escape"],
|
||||
"semicolon": [true, "never", "ignore-bound-class-methods"],
|
||||
"typedef-whitespace": [
|
||||
true,
|
||||
{
|
||||
"call-signature": "nospace",
|
||||
"index-signature": "nospace",
|
||||
"parameter": "nospace",
|
||||
"property-declaration": "nospace",
|
||||
"variable-declaration": "nospace"
|
||||
},
|
||||
{
|
||||
"call-signature": "onespace",
|
||||
"index-signature": "onespace",
|
||||
"parameter": "onespace",
|
||||
"property-declaration": "onespace",
|
||||
"variable-declaration": "onespace"
|
||||
}
|
||||
],
|
||||
"no-internal-module": true,
|
||||
"no-trailing-whitespace": true,
|
||||
"no-null-keyword": true,
|
||||
"jsdoc-format": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user