mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
fix eslint issues in CLI project (#7492)
This commit is contained in:
parent
3205a3da7c
commit
f9be037c4f
@ -19,14 +19,14 @@
|
|||||||
"eslint-plugin-rxjs"
|
"eslint-plugin-rxjs"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"prefer-arrow/prefer-arrow-functions": "warn",
|
"prefer-arrow/prefer-arrow-functions": "off",
|
||||||
"@typescript-eslint/no-var-requires": "warn",
|
"@typescript-eslint/no-var-requires": "off",
|
||||||
"@typescript-eslint/naming-convention": "warn",
|
"@typescript-eslint/naming-convention": "warn",
|
||||||
"quote-props": "warn",
|
"quote-props": "warn",
|
||||||
"no-shadow": "warn",
|
"no-shadow": "warn",
|
||||||
"@typescript-eslint/consistent-type-assertions": "warn",
|
"@typescript-eslint/consistent-type-assertions": "warn",
|
||||||
"@typescript-eslint/prefer-for-of": "warn",
|
"@typescript-eslint/prefer-for-of": "off",
|
||||||
"no-underscore-dangle": "warn",
|
"no-underscore-dangle": ["error", { "allowAfterThis": true }],
|
||||||
|
|
||||||
"@angular-eslint/component-selector": [
|
"@angular-eslint/component-selector": [
|
||||||
"error",
|
"error",
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
import * as shell from 'shelljs';
|
import * as shell from 'shelljs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as program from 'commander';
|
import * as program from 'commander';
|
||||||
|
@ -70,19 +70,19 @@ async function checkDiskSpaceFullEnv() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
folder = await alfrescoJsApi.nodes.addNode('-my-', {
|
folder = await alfrescoJsApi.nodes.addNode('-my-', {
|
||||||
'name': `try-env`,
|
name: `try-env`,
|
||||||
'relativePath': `Builds`,
|
relativePath: `Builds`,
|
||||||
'nodeType': 'cm:folder'
|
nodeType: 'cm:folder'
|
||||||
}, {}, {
|
}, {}, {
|
||||||
'overwrite': true
|
overwrite: true
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
folder = await alfrescoJsApi.nodes.getNode('-my-', {
|
folder = await alfrescoJsApi.nodes.getNode('-my-', {
|
||||||
'relativePath': `Builds/try-env`,
|
relativePath: `Builds/try-env`,
|
||||||
'nodeType': 'cm:folder'
|
nodeType: 'cm:folder'
|
||||||
}, {}, {
|
}, {}, {
|
||||||
'overwrite': true
|
overwrite: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const pathFile = path.join(__dirname, '../', 'README.md');
|
const pathFile = path.join(__dirname, '../', 'README.md');
|
||||||
@ -95,9 +95,9 @@ async function checkDiskSpaceFullEnv() {
|
|||||||
folder.entry.id,
|
folder.entry.id,
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
'name': 'README.md',
|
name: 'README.md',
|
||||||
'nodeType': 'cm:content',
|
nodeType: 'cm:content',
|
||||||
'autoRename': true
|
autoRename: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -22,9 +22,10 @@ import * as program from 'commander';
|
|||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-shadow
|
||||||
enum TARGETS {
|
enum TARGETS {
|
||||||
Publish = 'publish',
|
publish = 'publish',
|
||||||
Link = 'link'
|
link = 'link'
|
||||||
}
|
}
|
||||||
|
|
||||||
const DOCKER_FILENAME = 'Dockerfile';
|
const DOCKER_FILENAME = 'Dockerfile';
|
||||||
@ -105,7 +106,7 @@ function main(args) {
|
|||||||
.option('--sourceTag [type]', 'sourceTag')
|
.option('--sourceTag [type]', 'sourceTag')
|
||||||
.option('--buildArgs [type...]', 'buildArgs')
|
.option('--buildArgs [type...]', 'buildArgs')
|
||||||
.option('--fileName [type...]', 'Docker file name', DOCKER_FILENAME)
|
.option('--fileName [type...]', 'Docker file name', DOCKER_FILENAME)
|
||||||
.option('--target [type]', 'target: publish or link', TARGETS.Publish)
|
.option('--target [type]', 'target: publish or link', TARGETS.publish)
|
||||||
.requiredOption('--dockerRepo [type]', 'docker repo')
|
.requiredOption('--dockerRepo [type]', 'docker repo')
|
||||||
.requiredOption('--dockerTags [type]', ' tags')
|
.requiredOption('--dockerTags [type]', ' tags')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
@ -120,13 +121,13 @@ function main(args) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (program.opts().target === TARGETS.Publish && args.buildArgs === undefined) {
|
if (program.opts().target === TARGETS.publish && args.buildArgs === undefined) {
|
||||||
logger.error(`error: required option --buildArgs [type] in case the target is ${TARGETS.Publish}`);
|
logger.error(`error: required option --buildArgs [type] in case the target is ${TARGETS.publish}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (program.opts().target === TARGETS.Link && args.sourceTag === undefined) {
|
if (program.opts().target === TARGETS.link && args.sourceTag === undefined) {
|
||||||
logger.error(`error: required option --sourceTag [type] in case the target is ${TARGETS.Link}`);
|
logger.error(`error: required option --sourceTag [type] in case the target is ${TARGETS.link}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +148,7 @@ function main(args) {
|
|||||||
args.dockerTags.split(',').forEach((tag, index) => {
|
args.dockerTags.split(',').forEach((tag, index) => {
|
||||||
if (tag) {
|
if (tag) {
|
||||||
logger.info(`Analyzing tag:${tag} ... for target ${program.opts().target}`);
|
logger.info(`Analyzing tag:${tag} ... for target ${program.opts().target}`);
|
||||||
if (program.opts().target === TARGETS.Publish) {
|
if (program.opts().target === TARGETS.publish) {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
logger.info(`Build only once`);
|
logger.info(`Build only once`);
|
||||||
mainTag = tag;
|
mainTag = tag;
|
||||||
|
@ -18,14 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as program from 'commander';
|
import * as program from 'commander';
|
||||||
|
|
||||||
/* eslint-disable */
|
|
||||||
import request = require('request');
|
import request = require('request');
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
import { AlfrescoApi } from '@alfresco/js-api';
|
import { AlfrescoApi } from '@alfresco/js-api';
|
||||||
const ACTIVITI_CLOUD_APPS = require('./resources').ACTIVITI_CLOUD_APPS;
|
const ACTIVITI_CLOUD_APPS = require('./resources').ACTIVITI_CLOUD_APPS;
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
let alfrescoJsApiModeler: any;
|
let alfrescoJsApiModeler: any;
|
||||||
let alfrescoJsApiDevops: any;
|
let alfrescoJsApiDevops: any;
|
||||||
@ -369,11 +366,11 @@ async function checkIfAppIsReleased(missingApps: any [], tag?: string) {
|
|||||||
await checkDescriptorExist(currentAbsentApp.name);
|
await checkDescriptorExist(currentAbsentApp.name);
|
||||||
await sleep(TIME);
|
await sleep(TIME);
|
||||||
const deployPayload = {
|
const deployPayload = {
|
||||||
'name': currentAbsentApp.name,
|
name: currentAbsentApp.name,
|
||||||
'releaseId': projectRelease.entry.id,
|
releaseId: projectRelease.entry.id,
|
||||||
'security': currentAbsentApp.security,
|
security: currentAbsentApp.security,
|
||||||
'infrastructure': currentAbsentApp.infrastructure,
|
infrastructure: currentAbsentApp.infrastructure,
|
||||||
'variables': currentAbsentApp.variables
|
variables: currentAbsentApp.variables
|
||||||
};
|
};
|
||||||
await deploy(deployPayload);
|
await deploy(deployPayload);
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
/* eslint-disable */
|
const alfrescoApi = require('@alfresco/js-api');
|
||||||
let alfrescoApi = require('@alfresco/js-api');
|
const program = require('commander');
|
||||||
let program = require('commander');
|
const fs = require ('fs');
|
||||||
let fs = require ('fs');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
const { SharedlinksApi, FavoritesApi, NodesApi } = require('@alfresco/js-api');
|
const { SharedlinksApi, FavoritesApi, NodesApi } = require('@alfresco/js-api');
|
||||||
let MAX_RETRY = 10;
|
const MAX_RETRY = 10;
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
let TIMEOUT = 6000;
|
const TIMEOUT = 6000;
|
||||||
const ACS_DEFAULT = require('./resources').ACS_DEFAULT;
|
const ACS_DEFAULT = require('./resources').ACS_DEFAULT;
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
let alfrescoJsApi;
|
let alfrescoJsApi;
|
||||||
|
|
||||||
|
@ -1,19 +1,18 @@
|
|||||||
/* eslint-disable */
|
const alfrescoApi = require('@alfresco/js-api');
|
||||||
let alfrescoApi = require('@alfresco/js-api');
|
const program = require('commander');
|
||||||
let program = require('commander');
|
const fs = require ('fs');
|
||||||
let fs = require ('fs');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
const { throwError } = require('rxjs');
|
const { throwError } = require('rxjs');
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
const { AppDefinitionsApi, RuntimeAppDefinitionsApi } = require('@alfresco/js-api');
|
const { AppDefinitionsApi, RuntimeAppDefinitionsApi } = require('@alfresco/js-api');
|
||||||
let MAX_RETRY = 10;
|
const MAX_RETRY = 10;
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
let TIMEOUT = 6000;
|
const TIMEOUT = 6000;
|
||||||
const TENANT_DEFAULT_ID = 1;
|
const TENANT_DEFAULT_ID = 1;
|
||||||
const TENANT_DEFAULT_NAME = 'default';
|
const TENANT_DEFAULT_NAME = 'default';
|
||||||
const CONTENT_DEFAULT_NAME = 'adw-content';
|
const CONTENT_DEFAULT_NAME = 'adw-content';
|
||||||
const ACTIVITI_APPS = require('./resources').ACTIVITI_APPS;
|
const ACTIVITI_APPS = require('./resources').ACTIVITI_APPS;
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
let alfrescoJsApi;
|
let alfrescoJsApi;
|
||||||
let alfrescoJsApiRepo;
|
let alfrescoJsApiRepo;
|
||||||
@ -162,9 +161,9 @@ async function hasDefaultTenant(tenantId, tenantName) {
|
|||||||
|
|
||||||
async function createDefaultTenant(tenantName) {
|
async function createDefaultTenant(tenantName) {
|
||||||
const tenantPost = {
|
const tenantPost = {
|
||||||
'active': true,
|
active: true,
|
||||||
'maxUsers': 10000,
|
maxUsers: 10000,
|
||||||
'name' : tenantName
|
name : tenantName
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -180,13 +179,13 @@ async function createUsers(tenandId, user) {
|
|||||||
logger.info(`Create user ${user.email} on tenant: ${tenandId}`);
|
logger.info(`Create user ${user.email} on tenant: ${tenandId}`);
|
||||||
const passwordCamelCase = 'Password';
|
const passwordCamelCase = 'Password';
|
||||||
const userJson = {
|
const userJson = {
|
||||||
'email': user.email,
|
email: user.email,
|
||||||
'firstName': user.firstName,
|
firstName: user.firstName,
|
||||||
'lastName': user.lastName,
|
lastName: user.lastName,
|
||||||
'status': 'active',
|
status: 'active',
|
||||||
'type': 'enterprise',
|
type: 'enterprise',
|
||||||
'password': passwordCamelCase,
|
password: passwordCamelCase,
|
||||||
'tenantId': tenandId
|
tenantId: tenandId
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
65
lib/cli/scripts/kube-utils.ts
Normal file
65
lib/cli/scripts/kube-utils.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import { logger } from './logger';
|
||||||
|
import { exec } from './exec';
|
||||||
|
|
||||||
|
export interface KubeArgs {
|
||||||
|
tag?: string;
|
||||||
|
installCheck?: boolean;
|
||||||
|
username?: string;
|
||||||
|
token?: string;
|
||||||
|
clusterEnv?: string;
|
||||||
|
clusterUrl?: string;
|
||||||
|
dockerRepo?: string;
|
||||||
|
label?: string;
|
||||||
|
namespaces?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const setCluster = (clusterEnv: string, clusterUrl: string) => {
|
||||||
|
logger.info('Perform set-cluster...');
|
||||||
|
const response = exec('kubectl', [`config`, `set-cluster`, `${clusterEnv}`, `--server=${clusterUrl}`], {});
|
||||||
|
logger.info(response);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const setCredentials = (username: string, token: string) => {
|
||||||
|
logger.info('Perform set-credentials...');
|
||||||
|
const response = exec('kubectl', [`config`, `set-credentials`, `${username}`, `--token=${token}`], {});
|
||||||
|
logger.info(response);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const setContext = (clusterEnv: string, username: string) => {
|
||||||
|
logger.info('Perform set-context...');
|
||||||
|
const response = exec('kubectl', [`config`, `set-context`, `${clusterEnv}`, `--cluster=${clusterEnv}`, `--user=${username}`], {});
|
||||||
|
logger.info(response);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useContext = (clusterEnv: string) => {
|
||||||
|
logger.info('Perform use-context...');
|
||||||
|
const response = exec('kubectl', [`config`, `use-context`, `${clusterEnv}`], {});
|
||||||
|
logger.info(response);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deletePod = (args: KubeArgs) => {
|
||||||
|
logger.info('Perform delete pods...');
|
||||||
|
const response = exec('kubectl', [`delete`, `pods`, `--all-namespaces`, `-l`, `app=${args.label}`], {});
|
||||||
|
logger.info(response);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getNamespaces = (): string[] => {
|
||||||
|
logger.info('Perform get namespaces name...');
|
||||||
|
const result = exec('kubectl', [`get`, `namespaces`, `-l`, `type=application`, `-o`, `name`], {});
|
||||||
|
const namespaces = result.replace(/namespace[\/]+/g, '').split(/\r?\n/);
|
||||||
|
logger.info(`namespaces found: ${namespaces}`);
|
||||||
|
return namespaces;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getDeploymentName = (args: KubeArgs, namespace: string): string => {
|
||||||
|
logger.info('Perform get deployment name...');
|
||||||
|
const result = exec('kubectl', [`get`, `deployments`, `--namespace=${namespace}`, `-l`, `app=${args.label}`, `-o`, `name`], {});
|
||||||
|
logger.info(`deployment name: ${result}`);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const setImage = (args: KubeArgs, deploymentName: string, serviceName: string, namespace: string) => {
|
||||||
|
logger.info('Perform set image...');
|
||||||
|
const response = exec('kubectl', [`set`, `image`, `--namespace=${namespace}`, `${deploymentName}`, `${serviceName}=${args.dockerRepo}:${args.tag}`], {});
|
||||||
|
logger.info(response);
|
||||||
|
};
|
@ -19,13 +19,9 @@
|
|||||||
|
|
||||||
import * as program from 'commander';
|
import * as program from 'commander';
|
||||||
import moment from 'moment-es6';
|
import moment from 'moment-es6';
|
||||||
import { exec } from './exec';
|
|
||||||
/* eslint-disable */
|
|
||||||
import { AlfrescoApi } from '@alfresco/js-api';
|
import { AlfrescoApi } from '@alfresco/js-api';
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
|
import * as kube from './kube-utils';
|
||||||
export interface ConfigArgs {
|
export interface ConfigArgs {
|
||||||
rancherUsername?: string;
|
rancherUsername?: string;
|
||||||
rancherToken?: string;
|
rancherToken?: string;
|
||||||
@ -42,7 +38,6 @@ export interface ConfigArgs {
|
|||||||
identityHost: boolean;
|
identityHost: boolean;
|
||||||
enableLike: boolean;
|
enableLike: boolean;
|
||||||
intervalTime: string;
|
intervalTime: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAlfrescoJsApiInstance(args: ConfigArgs) {
|
function getAlfrescoJsApiInstance(args: ConfigArgs) {
|
||||||
@ -185,36 +180,12 @@ async function undeployApplication(args: ConfigArgs, apiService: any, name: stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCluster(args: ConfigArgs) {
|
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
||||||
logger.info('Perform set-cluster...');
|
|
||||||
const response = exec('kubectl', [`config`, `set-cluster`, `${args.clusterEnv}`, `--server=${args.clusterUrl}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCredentials(args: ConfigArgs) {
|
|
||||||
logger.info('Perform set-credentials...');
|
|
||||||
const response = exec('kubectl', [`config`, `set-credentials`, `${args.rancherUsername}`, `--token=${args.rancherToken}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setContext(args: ConfigArgs) {
|
|
||||||
logger.info('Perform set-context...');
|
|
||||||
const response = exec('kubectl', [`config`, `set-context`, `${args.clusterEnv}`, `--cluster=${args.clusterEnv}`, `--user=${args.rancherUsername}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function useContext(args: ConfigArgs) {
|
|
||||||
logger.info('Perform use-context...');
|
|
||||||
const response = exec('kubectl', [`config`, `use-context`, `${args.clusterEnv}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async function(args: ConfigArgs) {
|
export default async function(args: ConfigArgs) {
|
||||||
await main(args);
|
await main(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main(args) {
|
const main = async (args: ConfigArgs) => {
|
||||||
|
|
||||||
program
|
program
|
||||||
.version('0.1.0')
|
.version('0.1.0')
|
||||||
.description('The following command is in charge of cleaning the releases/application/descriptor related to an app passed as input' +
|
.description('The following command is in charge of cleaning the releases/application/descriptor related to an app passed as input' +
|
||||||
@ -254,24 +225,27 @@ async function main(args) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (args.apps !== undefined) {
|
if (args.apps !== undefined) {
|
||||||
setCluster(args);
|
kube.setCluster(args.clusterEnv, args.clusterUrl);
|
||||||
setCredentials(args);
|
kube.setCredentials(args.rancherUsername, args.rancherToken);
|
||||||
setContext(args);
|
kube.setContext(args.clusterEnv, args.rancherUsername);
|
||||||
useContext(args);
|
kube.useContext(args.clusterEnv);
|
||||||
|
|
||||||
const applications = args.apps.includes(',') ? args.apps.split(',') : [args.apps];
|
const applications = args.apps.includes(',') ? args.apps.split(',') : [args.apps];
|
||||||
const interval = args.intervalTime ? args.intervalTime : '30 min';
|
const interval = args.intervalTime ? args.intervalTime : '30 min';
|
||||||
const extractTimeRange = interval.split(' ')[0];
|
const extractTimeRange = parseInt(interval.split(' ')[0], 10);
|
||||||
logger.info(`Extract time ${extractTimeRange} from interval: ${interval}`);
|
logger.info(`Extract time ${extractTimeRange} from interval: ${interval}`);
|
||||||
|
|
||||||
for (let i = 0; i < applications.length; i++ ) {
|
for (let i = 0; i < applications.length; i++ ) {
|
||||||
logger.info(`Perform action on app: ${applications[i]}`);
|
logger.info(`Perform action on app: ${applications[i]}`);
|
||||||
if (args.enableLike) {
|
if (args.enableLike) {
|
||||||
const applicationsByName = await getApplicationsByName(args, alfrescoJsApiDevops, applications[i]);
|
const applicationsByName = await getApplicationsByName(args, alfrescoJsApiDevops, applications[i]);
|
||||||
logger.info(`Found ${applicationsByName.length} apps`);
|
logger.info(`Found ${applicationsByName.length} apps`);
|
||||||
|
|
||||||
for (let y = 0; y < applicationsByName.length; y++ ) {
|
for (let y = 0; y < applicationsByName.length; y++ ) {
|
||||||
const application = applicationsByName[y].entry;
|
const application = applicationsByName[y].entry;
|
||||||
logger.info(`Analyze app: ${application.name} `);
|
logger.info(`Analyze app: ${application.name} `);
|
||||||
const diffAsMinutes = moment.duration(moment().diff(moment(application.createdAt))).asMinutes();
|
const diffAsMinutes = moment.duration(moment().diff(moment(application.createdAt))).asMinutes();
|
||||||
|
|
||||||
if (diffAsMinutes > extractTimeRange) {
|
if (diffAsMinutes > extractTimeRange) {
|
||||||
logger.info(`The app: ${application} is older than ${interval}. Can delete it`);
|
logger.info(`The app: ${application} is older than ${interval}. Can delete it`);
|
||||||
await undeployApplication(args, alfrescoJsApiDevops, application.name);
|
await undeployApplication(args, alfrescoJsApiDevops, application.name);
|
||||||
@ -288,5 +262,4 @@ async function main(args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
|
||||||
|
@ -17,54 +17,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { exec } from './exec';
|
|
||||||
import * as program from 'commander';
|
import * as program from 'commander';
|
||||||
import { logger } from './logger';
|
import * as kube from './kube-utils';
|
||||||
|
|
||||||
export interface KubeArgs {
|
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
||||||
username?: string;
|
export default function(args: kube.KubeArgs) {
|
||||||
token?: string;
|
|
||||||
clusterEnv?: string;
|
|
||||||
clusterUrl?: string;
|
|
||||||
label?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCluster(args: KubeArgs) {
|
|
||||||
logger.info('Perform set-cluster...');
|
|
||||||
const response = exec('kubectl', [`config`, `set-cluster`, `${args.clusterEnv}`, `--server=${args.clusterUrl}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCredentials(args: KubeArgs) {
|
|
||||||
logger.info('Perform set-credentials...');
|
|
||||||
const response = exec('kubectl', [`config`, `set-credentials`, `${args.username}`, `--token=${args.token}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setContext(args: KubeArgs) {
|
|
||||||
logger.info('Perform set-context...');
|
|
||||||
const response = exec('kubectl', [`config`, `set-context`, `${args.clusterEnv}`, `--cluster=${args.clusterEnv}`, `--user=${args.username}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function useContext(args: KubeArgs) {
|
|
||||||
logger.info('Perform use-context...');
|
|
||||||
const response = exec('kubectl', [`config`, `use-context`, `${args.clusterEnv}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function deletePod(args: KubeArgs) {
|
|
||||||
logger.info('Perform delete pods...');
|
|
||||||
const response = exec('kubectl', [`delete`, `pods`, `--all-namespaces`, `-l`, `app=${args.label}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function(args: KubeArgs) {
|
|
||||||
main(args);
|
main(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function main(args) {
|
const main = (args: kube.KubeArgs) => {
|
||||||
|
|
||||||
program
|
program
|
||||||
.version('0.1.0')
|
.version('0.1.0')
|
||||||
.option('--username [type]', 'username')
|
.option('--username [type]', 'username')
|
||||||
@ -81,10 +42,10 @@ function main(args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.label !== undefined) {
|
if (args.label !== undefined) {
|
||||||
setCluster(args);
|
kube.setCluster(args.clusterEnv, args.clusterUrl);
|
||||||
setCredentials(args);
|
kube.setCredentials(args.username, args.token);
|
||||||
setContext(args);
|
kube.setContext(args.clusterEnv, args.username);
|
||||||
useContext(args);
|
kube.useContext(args.clusterEnv);
|
||||||
deletePod(args);
|
kube.deletePod(args);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
@ -20,77 +20,21 @@
|
|||||||
import { exec } from './exec';
|
import { exec } from './exec';
|
||||||
import * as program from 'commander';
|
import * as program from 'commander';
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
|
import * as kube from './kube-utils';
|
||||||
|
|
||||||
export interface KubeArgs {
|
const installPerform = () => {
|
||||||
tag?: string;
|
|
||||||
installCheck?: boolean;
|
|
||||||
username?: string;
|
|
||||||
token?: string;
|
|
||||||
clusterEnv?: string;
|
|
||||||
clusterUrl?: string;
|
|
||||||
dockerRepo?: string;
|
|
||||||
label?: string;
|
|
||||||
namespaces?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCluster(args: KubeArgs) {
|
|
||||||
logger.info('Perform set-cluster...');
|
|
||||||
const response = exec('kubectl', [`config`, `set-cluster`, `${args.clusterEnv}`, `--server=${args.clusterUrl}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCredentials(args: KubeArgs) {
|
|
||||||
logger.info('Perform set-credentials...');
|
|
||||||
const response = exec('kubectl', [`config`, `set-credentials`, `${args.username}`, `--token=${args.token}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setContext(args: KubeArgs) {
|
|
||||||
logger.info('Perform set-context...');
|
|
||||||
const response = exec('kubectl', [`config`, `set-context`, `${args.clusterEnv}`, `--cluster=${args.clusterEnv}`, `--user=${args.username}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function useContext(args: KubeArgs) {
|
|
||||||
logger.info('Perform use-context...');
|
|
||||||
const response = exec('kubectl', [`config`, `use-context`, `${args.clusterEnv}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNamespaces(): string [] {
|
|
||||||
logger.info('Perform get namespaces name...');
|
|
||||||
const result = exec('kubectl', [`get`, `namespaces`, `-l`, `type=application`, `-o`, `name`], {});
|
|
||||||
const namespaces = result.replace(/namespace[\/]+/g, '').split(/\r?\n/);
|
|
||||||
logger.info(`namespaces found: ${namespaces}`);
|
|
||||||
return namespaces;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDeploymentName(args: KubeArgs, namespace: string): string {
|
|
||||||
logger.info('Perform get deployment name...');
|
|
||||||
const result = exec('kubectl', [`get`, `deployments`, `--namespace=${namespace}`, `-l`, `app=${args.label}`, `-o`, `name`], {});
|
|
||||||
logger.info(`deployment name: ${result}`);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setImage(args: KubeArgs, deploymentName: string, serviceName: string, namespace: string) {
|
|
||||||
logger.info('Perform set image...');
|
|
||||||
const response = exec('kubectl', [`set`, `image`, `--namespace=${namespace}`, `${deploymentName}`, `${serviceName}=${args.dockerRepo}:${args.tag}`], {});
|
|
||||||
logger.info(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
function installPerform() {
|
|
||||||
logger.info('Perform install...');
|
logger.info('Perform install...');
|
||||||
const responseK8sStable = exec('curl', [`-s`, `https://storage.googleapis.com/kubernetes-release/release/stable.txt`], {}).trim();
|
const responseK8sStable = exec('curl', [`-s`, `https://storage.googleapis.com/kubernetes-release/release/stable.txt`], {}).trim();
|
||||||
const k8sRelease = `https://storage.googleapis.com/kubernetes-release/release/${responseK8sStable}/bin/linux/amd64/kubectl`;
|
const k8sRelease = `https://storage.googleapis.com/kubernetes-release/release/${responseK8sStable}/bin/linux/amd64/kubectl`;
|
||||||
exec('curl', [`LO`, `${k8sRelease}`], {});
|
exec('curl', [`LO`, `${k8sRelease}`], {});
|
||||||
}
|
};
|
||||||
|
|
||||||
export default function(args: KubeArgs) {
|
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
||||||
|
export default function(args: kube.KubeArgs) {
|
||||||
main(args);
|
main(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function main(args) {
|
const main = (args: kube.KubeArgs) => {
|
||||||
|
|
||||||
program
|
program
|
||||||
.version('0.1.0')
|
.version('0.1.0')
|
||||||
.description('his command allows you to update a specific service on the rancher env with a specific tag \n\n' +
|
.description('his command allows you to update a specific service on the rancher env with a specific tag \n\n' +
|
||||||
@ -115,27 +59,28 @@ function main(args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.tag !== undefined) {
|
if (args.tag !== undefined) {
|
||||||
setCluster(args);
|
kube.setCluster(args.clusterEnv, args.clusterUrl);
|
||||||
setCredentials(args);
|
kube.setCredentials(args.username, args.token);
|
||||||
setContext(args);
|
kube.setContext(args.clusterEnv, args.username);
|
||||||
useContext(args);
|
kube.useContext(args.clusterEnv);
|
||||||
|
|
||||||
let namespaces: string [];
|
let namespaces: string [];
|
||||||
if (args.namespaces === null || args.namespaces === 'default') {
|
if (args.namespaces === null || args.namespaces === 'default') {
|
||||||
logger.info(`No namespaces provided. Fetch all of them`);
|
logger.info(`No namespaces provided. Fetch all of them`);
|
||||||
namespaces = getNamespaces();
|
namespaces = kube.getNamespaces();
|
||||||
} else {
|
} else {
|
||||||
namespaces = args.namespaces.split(',');
|
namespaces = args.namespaces.split(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
namespaces.forEach((namespace) => {
|
namespaces.forEach((namespace) => {
|
||||||
logger.info(`Find deployment name based on label ${args.label} and namespace ${namespace}`);
|
logger.info(`Find deployment name based on label ${args.label} and namespace ${namespace}`);
|
||||||
const deploymentName = getDeploymentName(args, namespace);
|
const deploymentName = kube.getDeploymentName(args, namespace);
|
||||||
if (deploymentName) {
|
if (deploymentName) {
|
||||||
logger.info(`Found ${deploymentName}`);
|
logger.info(`Found ${deploymentName}`);
|
||||||
setImage(args, deploymentName.trim(), '*', namespace);
|
kube.setImage(args, deploymentName.trim(), '*', namespace);
|
||||||
} else {
|
} else {
|
||||||
logger.info(`No container with the label app=${args.label} found`);
|
logger.info(`No container with the label app=${args.label} found`);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
@ -32,8 +32,8 @@ interface PackageInfo {
|
|||||||
|
|
||||||
const nonStandardLicenses = {
|
const nonStandardLicenses = {
|
||||||
'public domain': 'PDDL-1.0',
|
'public domain': 'PDDL-1.0',
|
||||||
'apache': 'Apache-2.0',
|
apache: 'Apache-2.0',
|
||||||
'bsd': 'BSD-2-Clause'
|
bsd: 'BSD-2-Clause'
|
||||||
};
|
};
|
||||||
|
|
||||||
const missingRepositories = {
|
const missingRepositories = {
|
||||||
@ -44,7 +44,7 @@ const missingRepositories = {
|
|||||||
'@webassemblyjs/leb128': 'https://github.com/xtuc/webassemblyjs',
|
'@webassemblyjs/leb128': 'https://github.com/xtuc/webassemblyjs',
|
||||||
'adf-tslint-rules': 'https://github.com/Alfresco/alfresco-ng2-components',
|
'adf-tslint-rules': 'https://github.com/Alfresco/alfresco-ng2-components',
|
||||||
'adf-monaco-extension': 'https://github.com/eromano/aca-monaco-extension',
|
'adf-monaco-extension': 'https://github.com/eromano/aca-monaco-extension',
|
||||||
'indexof': 'https://github.com/component/indexof',
|
indexof: 'https://github.com/component/indexof',
|
||||||
'rxjs-compat': 'https://github.com/ReactiveX/rxjs/tree/master/compat'
|
'rxjs-compat': 'https://github.com/ReactiveX/rxjs/tree/master/compat'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { logger } from './../logger';
|
import { logger } from './../logger';
|
||||||
import alfrescoApi = require('@alfresco/js-api');
|
import alfrescoApi = require('@alfresco/js-api');
|
||||||
|
|
||||||
|
const TIMEOUT = 6000;
|
||||||
|
const MAX_RETRY = 10;
|
||||||
export class CheckEnv {
|
export class CheckEnv {
|
||||||
_alfrescoJsApi: any;
|
_alfrescoJsApi: any;
|
||||||
TIMEOUT = 6000;
|
|
||||||
MAX_RETRY = 10;
|
|
||||||
counter = 0;
|
counter = 0;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -15,7 +15,7 @@ export class CheckEnv {
|
|||||||
|
|
||||||
async checkEnv() {
|
async checkEnv() {
|
||||||
try {
|
try {
|
||||||
this.alfrescoJsApi = new alfrescoApi.AlfrescoApiCompatibility(<any> {
|
this.alfrescoJsApi = new alfrescoApi.AlfrescoApiCompatibility({
|
||||||
provider: 'ALL',
|
provider: 'ALL',
|
||||||
hostBpm: this.host,
|
hostBpm: this.host,
|
||||||
hostEcm: this.host,
|
hostEcm: this.host,
|
||||||
@ -25,7 +25,7 @@ export class CheckEnv {
|
|||||||
clientId: 'alfresco',
|
clientId: 'alfresco',
|
||||||
scope: 'openid'
|
scope: 'openid'
|
||||||
}
|
}
|
||||||
});
|
} as any);
|
||||||
await this.alfrescoJsApi.login(this.username, this.password);
|
await this.alfrescoJsApi.login(this.username, this.password);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.error.code === 'ETIMEDOUT') {
|
if (e.error.code === 'ETIMEDOUT') {
|
||||||
@ -34,14 +34,14 @@ export class CheckEnv {
|
|||||||
}
|
}
|
||||||
logger.error('Login error environment down or inaccessible');
|
logger.error('Login error environment down or inaccessible');
|
||||||
this.counter++;
|
this.counter++;
|
||||||
if (this.MAX_RETRY === this.counter) {
|
if (MAX_RETRY === this.counter) {
|
||||||
logger.error('Give up');
|
logger.error('Give up');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
} else {
|
} else {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Retry in 1 minute at main();tempt N ${this.counter}`
|
`Retry in 1 minute at main();tempt N ${this.counter}`
|
||||||
);
|
);
|
||||||
this.sleep(this.TIMEOUT);
|
this.sleep(TIMEOUT);
|
||||||
this.checkEnv();
|
this.checkEnv();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
import { logger } from '../logger';
|
import { logger } from '../logger';
|
||||||
import { PluginInterface } from './plugin-model';
|
import { PluginInterface } from './plugin-model';
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// eslint-disable-next-line no-shadow
|
||||||
export enum PluginTarget {
|
export enum PluginTarget {
|
||||||
processService = 'processService',
|
processService = 'processService',
|
||||||
processAutomation = 'processAutomation',
|
processAutomation = 'processAutomation',
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
import { PluginInterface } from './plugin-model';
|
import { PluginInterface } from './plugin-model';
|
||||||
import { logger } from '../logger';
|
import { logger } from '../logger';
|
||||||
import { ProcessAutomationHealth } from './process-automation-health';
|
import { ProcessAutomationHealth } from './process-automation-health';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
import { PluginInterface } from './plugin-model';
|
import { PluginInterface } from './plugin-model';
|
||||||
import { logger } from '../logger';
|
import { logger } from '../logger';
|
||||||
import { ProcessServiceHealth } from './process-services-health';
|
import { ProcessServiceHealth } from './process-services-health';
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* cSpell:disable */
|
/* cSpell:disable */
|
||||||
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
export const ACTIVITI_CLOUD_APPS: any = {
|
export const ACTIVITI_CLOUD_APPS: any = {
|
||||||
SUB_PROCESS_APP: {
|
SUB_PROCESS_APP: {
|
||||||
name: 'subprocessapp',
|
name: 'subprocessapp',
|
||||||
@ -25,8 +27,8 @@ export const ACTIVITI_CLOUD_APPS: any = {
|
|||||||
processparent: 'processparent'
|
processparent: 'processparent'
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
{ 'role': 'ACTIVITI_ADMIN', 'groups': [], 'users': ['superadminuser'] },
|
{ role: 'ACTIVITI_ADMIN', groups: [], users: ['superadminuser'] },
|
||||||
{ 'role': 'ACTIVITI_USER', 'groups': ['hr', 'testgroup'], 'users': ['hruser'] }
|
{ role: 'ACTIVITI_USER', groups: ['hr', 'testgroup'], users: ['hruser'] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
CANDIDATE_BASE_APP: {
|
CANDIDATE_BASE_APP: {
|
||||||
@ -64,8 +66,8 @@ export const ACTIVITI_CLOUD_APPS: any = {
|
|||||||
outputform: 'outputform'
|
outputform: 'outputform'
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
{ 'role': 'ACTIVITI_ADMIN', 'groups': [], 'users': ['superadminuser', 'processadminuser'] },
|
{ role: 'ACTIVITI_ADMIN', groups: [], users: ['superadminuser', 'processadminuser'] },
|
||||||
{ 'role': 'ACTIVITI_USER', 'groups': ['hr', 'testgroup'], 'users': ['hruser', 'salesuser'] }
|
{ role: 'ACTIVITI_USER', groups: ['hr', 'testgroup'], users: ['hruser', 'salesuser'] }
|
||||||
],
|
],
|
||||||
tasks: {
|
tasks: {
|
||||||
uploadFileTask: 'UploadFileTask',
|
uploadFileTask: 'UploadFileTask',
|
||||||
@ -195,8 +197,8 @@ export const ACTIVITI_CLOUD_APPS: any = {
|
|||||||
uploadSingleMultipleFiles: 'UploadSingleMultipleFiles'
|
uploadSingleMultipleFiles: 'UploadSingleMultipleFiles'
|
||||||
},
|
},
|
||||||
security: [
|
security: [
|
||||||
{ 'role': 'ACTIVITI_ADMIN', 'groups': [], 'users': ['superadminuser', 'processadminuser'] },
|
{ role: 'ACTIVITI_ADMIN', groups: [], users: ['superadminuser', 'processadminuser'] },
|
||||||
{ 'role': 'ACTIVITI_USER', 'groups': ['hr', 'sales', 'testgroup'], 'users': ['hruser'] }
|
{ role: 'ACTIVITI_USER', groups: ['hr', 'sales', 'testgroup'], users: ['hruser'] }
|
||||||
],
|
],
|
||||||
infrastructure: {connectors: {restconnector: {}}, bridges: {}}
|
infrastructure: {connectors: {restconnector: {}}, bridges: {}}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function dotenv() {
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
return require('dotenv-expand')(require('dotenv'));
|
const expand = require('dotenv-expand');
|
||||||
}
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
const nodeDotEnv = require('dotenv');
|
||||||
|
|
||||||
export function dotenvConfig(params?: any) {
|
export const dotenv = () => expand(nodeDotEnv);
|
||||||
return require('dotenv-expand')(require('dotenv').config(params));
|
export const dotenvConfig = (params?: any) => expand(nodeDotEnv.config(params));
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user