mirror of https://github.com/portainer/portainer
chore(deps): upgrade eslint and use eslint-plugin (#4989)
parent
5fd92d8a3f
commit
ab30793c48
|
@ -133,7 +133,7 @@ angular.module('portainer.docker').factory('ImageService', [
|
|||
|
||||
Image.create({}, imageConfiguration)
|
||||
.$promise.then(function success(data) {
|
||||
var err = data.length > 0 && data[data.length - 1].hasOwnProperty('message');
|
||||
var err = data.length > 0 && data[data.length - 1].message;
|
||||
if (err) {
|
||||
var detail = data[data.length - 1];
|
||||
deferred.reject({ msg: detail.message });
|
||||
|
|
|
@ -16,7 +16,7 @@ angular.module('portainer.integrations.storidge').factory('StoridgeNodeService',
|
|||
var nodes = [];
|
||||
|
||||
for (var key in nodeData) {
|
||||
if (nodeData.hasOwnProperty(key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(nodeData, key)) {
|
||||
nodes.push(new StoridgeNodeModel(key, nodeData[key]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ angular.module('portainer.integrations.storidge').factory('StoridgeSnapshotServi
|
|||
var snapshotsData = data.snapshots;
|
||||
let snapshotsArray = [];
|
||||
for (const key in snapshotsData) {
|
||||
if (snapshotsData.hasOwnProperty(key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(snapshotsData, key)) {
|
||||
snapshotsArray.push(snapshotsData[key]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,6 @@ class KubernetesApplicationService {
|
|||
|
||||
/* #region GET */
|
||||
async getAsync(namespace, name) {
|
||||
try {
|
||||
const [deployment, daemonSet, statefulSet, pod, pods, autoScalers, ingresses] = await Promise.allSettled([
|
||||
this.KubernetesDeploymentService.get(namespace, name),
|
||||
this.KubernetesDaemonSetService.get(namespace, name),
|
||||
|
@ -100,8 +99,6 @@ class KubernetesApplicationService {
|
|||
this.KubernetesIngressService.get(namespace),
|
||||
]);
|
||||
|
||||
// const pod = _.find(pods.value, ['metadata.namespace', namespace, 'metadata.name', name]);
|
||||
|
||||
let rootItem;
|
||||
let converterFunc;
|
||||
if (deployment.status === 'fulfilled') {
|
||||
|
@ -145,13 +142,9 @@ class KubernetesApplicationService {
|
|||
// TODO: refactor @LP
|
||||
// append ingress yaml ?
|
||||
return application;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async getAllAsync(namespace) {
|
||||
try {
|
||||
const namespaces = namespace ? [namespace] : _.map(await this.KubernetesNamespaceService.get(), 'Name');
|
||||
|
||||
const convertToApplication = (item, converterFunc, services, pods, ingresses) => {
|
||||
|
@ -176,9 +169,7 @@ class KubernetesApplicationService {
|
|||
const deploymentApplications = _.map(deployments, (item) =>
|
||||
convertToApplication(item, KubernetesApplicationConverter.apiDeploymentToApplication, services, pods, ingresses)
|
||||
);
|
||||
const daemonSetApplications = _.map(daemonSets, (item) =>
|
||||
convertToApplication(item, KubernetesApplicationConverter.apiDaemonSetToApplication, services, pods, ingresses)
|
||||
);
|
||||
const daemonSetApplications = _.map(daemonSets, (item) => convertToApplication(item, KubernetesApplicationConverter.apiDaemonSetToApplication, services, pods, ingresses));
|
||||
const statefulSetApplications = _.map(statefulSets, (item) =>
|
||||
convertToApplication(item, KubernetesApplicationConverter.apiStatefulSetToapplication, services, pods, ingresses)
|
||||
);
|
||||
|
@ -202,9 +193,6 @@ class KubernetesApplicationService {
|
|||
})
|
||||
);
|
||||
return _.flatten(res);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
get(namespace, name) {
|
||||
|
@ -226,7 +214,6 @@ class KubernetesApplicationService {
|
|||
* also be displayed in the summary output (getCreatedApplicationResources)
|
||||
*/
|
||||
async createAsync(formValues) {
|
||||
try {
|
||||
let [app, headlessService, service, claims] = KubernetesApplicationConverter.applicationFormValuesToApplication(formValues);
|
||||
|
||||
if (service) {
|
||||
|
@ -259,9 +246,6 @@ class KubernetesApplicationService {
|
|||
}
|
||||
|
||||
await apiService.create(app);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
create(formValues) {
|
||||
|
@ -277,7 +261,6 @@ class KubernetesApplicationService {
|
|||
* in this method should also be displayed in the summary output (getUpdatedApplicationResources)
|
||||
*/
|
||||
async patchAsync(oldFormValues, newFormValues) {
|
||||
try {
|
||||
const [oldApp, oldHeadlessService, oldService, oldClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(oldFormValues);
|
||||
const [newApp, newHeadlessService, newService, newClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(newFormValues);
|
||||
const oldApiService = this._getApplicationApiService(oldApp);
|
||||
|
@ -343,14 +326,10 @@ class KubernetesApplicationService {
|
|||
await this.KubernetesHorizontalPodAutoScalerService.delete(oldAutoScaler);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// this function accepts KubernetesApplication as parameters
|
||||
async patchPartialAsync(oldApp, newApp) {
|
||||
try {
|
||||
const oldAppPayload = {
|
||||
Name: oldApp.Name,
|
||||
Namespace: oldApp.ResourcePool,
|
||||
|
@ -365,9 +344,6 @@ class KubernetesApplicationService {
|
|||
};
|
||||
const apiService = this._getApplicationApiService(oldApp);
|
||||
await apiService.patch(oldAppPayload, newAppPayload);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// accept either formValues or applications as parameters
|
||||
|
@ -384,7 +360,6 @@ class KubernetesApplicationService {
|
|||
|
||||
/* #region DELETE */
|
||||
async deleteAsync(application) {
|
||||
try {
|
||||
const payload = {
|
||||
Namespace: application.ResourcePool || application.Namespace,
|
||||
Name: application.Name,
|
||||
|
@ -418,9 +393,6 @@ class KubernetesApplicationService {
|
|||
if (!_.isEmpty(application.AutoScaler)) {
|
||||
await this.KubernetesHorizontalPodAutoScalerService.delete(application.AutoScaler);
|
||||
}
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
delete(application) {
|
||||
|
@ -430,13 +402,9 @@ class KubernetesApplicationService {
|
|||
|
||||
/* #region ROLLBACK */
|
||||
async rollbackAsync(application, targetRevision) {
|
||||
try {
|
||||
const payload = KubernetesApplicationRollbackHelper.getPatchPayload(application, targetRevision);
|
||||
const apiService = this._getApplicationApiService(application);
|
||||
await apiService.rollback(application.ResourcePool, application.Name, payload);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
rollback(application, targetRevision) {
|
||||
|
|
|
@ -26,7 +26,6 @@ class KubernetesConfigurationService {
|
|||
* GET
|
||||
*/
|
||||
async getAsync(namespace, name) {
|
||||
try {
|
||||
const [configMap, secret] = await Promise.allSettled([this.KubernetesConfigMapService.get(namespace, name), this.KubernetesSecretService.get(namespace, name)]);
|
||||
let configuration;
|
||||
if (secret.status === 'fulfilled') {
|
||||
|
@ -35,13 +34,9 @@ class KubernetesConfigurationService {
|
|||
}
|
||||
configuration = KubernetesConfigurationConverter.configMapToConfiguration(configMap.value);
|
||||
return configuration;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async getAllAsync(namespace) {
|
||||
try {
|
||||
const namespaces = namespace ? [namespace] : _.map(await this.KubernetesNamespaceService.get(), 'Name');
|
||||
const res = await Promise.all(
|
||||
_.map(namespaces, async (ns) => {
|
||||
|
@ -52,9 +47,6 @@ class KubernetesConfigurationService {
|
|||
})
|
||||
);
|
||||
return _.flatten(res);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
get(namespace, name) {
|
||||
|
@ -70,7 +62,6 @@ class KubernetesConfigurationService {
|
|||
async createAsync(formValues) {
|
||||
formValues.ConfigurationOwner = KubernetesCommonHelper.ownerToLabel(formValues.ConfigurationOwner);
|
||||
|
||||
try {
|
||||
if (formValues.Type === KubernetesConfigurationTypes.CONFIGMAP) {
|
||||
const configMap = KubernetesConfigMapConverter.configurationFormValuesToConfigMap(formValues);
|
||||
await this.KubernetesConfigMapService.create(configMap);
|
||||
|
@ -78,9 +69,6 @@ class KubernetesConfigurationService {
|
|||
const secret = KubernetesSecretConverter.configurationFormValuesToSecret(formValues);
|
||||
await this.KubernetesSecretService.create(secret);
|
||||
}
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
create(formValues) {
|
||||
|
@ -91,7 +79,6 @@ class KubernetesConfigurationService {
|
|||
* UPDATE
|
||||
*/
|
||||
async updateAsync(formValues, configuration) {
|
||||
try {
|
||||
if (formValues.Type === KubernetesConfigurationTypes.CONFIGMAP) {
|
||||
const configMap = KubernetesConfigMapConverter.configurationFormValuesToConfigMap(formValues);
|
||||
configMap.ConfigurationOwner = configuration.ConfigurationOwner;
|
||||
|
@ -101,9 +88,6 @@ class KubernetesConfigurationService {
|
|||
secret.ConfigurationOwner = configuration.ConfigurationOwner;
|
||||
await this.KubernetesSecretService.update(secret);
|
||||
}
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
update(formValues, configuration) {
|
||||
|
@ -114,15 +98,11 @@ class KubernetesConfigurationService {
|
|||
* DELETE
|
||||
*/
|
||||
async deleteAsync(config) {
|
||||
try {
|
||||
if (config.Type === KubernetesConfigurationTypes.CONFIGMAP) {
|
||||
await this.KubernetesConfigMapService.delete(config);
|
||||
} else {
|
||||
await this.KubernetesSecretService.delete(config);
|
||||
}
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
delete(config) {
|
||||
|
|
|
@ -14,7 +14,6 @@ export function KubernetesResourcePoolService($async, EndpointService, Kubernete
|
|||
};
|
||||
|
||||
async function getOne(name) {
|
||||
try {
|
||||
const namespace = await KubernetesNamespaceService.get(name);
|
||||
const [quotaAttempt] = await Promise.allSettled([KubernetesResourceQuotaService.get(name, KubernetesResourceQuotaHelper.generateResourceQuotaName(name))]);
|
||||
const pool = KubernetesResourcePoolConverter.apiToResourcePool(namespace);
|
||||
|
@ -23,13 +22,9 @@ export function KubernetesResourcePoolService($async, EndpointService, Kubernete
|
|||
pool.Yaml += '---\n' + quotaAttempt.value.Yaml;
|
||||
}
|
||||
return pool;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async function getAll() {
|
||||
try {
|
||||
const namespaces = await KubernetesNamespaceService.get();
|
||||
const pools = await Promise.all(
|
||||
_.map(namespaces, async (namespace) => {
|
||||
|
@ -44,9 +39,6 @@ export function KubernetesResourcePoolService($async, EndpointService, Kubernete
|
|||
})
|
||||
);
|
||||
return pools;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
function get(name) {
|
||||
|
@ -58,7 +50,6 @@ export function KubernetesResourcePoolService($async, EndpointService, Kubernete
|
|||
|
||||
function create(formValues) {
|
||||
return $async(async () => {
|
||||
try {
|
||||
const [namespace, quota, ingresses, registries] = KubernetesResourcePoolConverter.formValuesToResourcePool(formValues);
|
||||
await KubernetesNamespaceService.create(namespace);
|
||||
|
||||
|
@ -71,15 +62,11 @@ export function KubernetesResourcePoolService($async, EndpointService, Kubernete
|
|||
const endpointId = formValues.EndpointId;
|
||||
const registriesPromises = _.map(registries, (r) => EndpointService.updateRegistryAccess(endpointId, r.Id, r.RegistryAccesses[endpointId]));
|
||||
await Promise.all(registriesPromises);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function patch(oldFormValues, newFormValues) {
|
||||
return $async(async () => {
|
||||
try {
|
||||
const [oldNamespace, oldQuota, oldIngresses, oldRegistries] = KubernetesResourcePoolConverter.formValuesToResourcePool(oldFormValues);
|
||||
const [newNamespace, newQuota, newIngresses, newRegistries] = KubernetesResourcePoolConverter.formValuesToResourcePool(newFormValues);
|
||||
void oldNamespace, newNamespace;
|
||||
|
@ -119,19 +106,12 @@ export function KubernetesResourcePoolService($async, EndpointService, Kubernete
|
|||
});
|
||||
|
||||
await Promise.all(_.concat(newRegistriesPromises, removedRegistriesPromises));
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _delete(pool) {
|
||||
return $async(async () => {
|
||||
try {
|
||||
await KubernetesNamespaceService.delete(pool.Namespace);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,13 +14,9 @@ class KubernetesStackService {
|
|||
* GET
|
||||
*/
|
||||
async getAllAsync(namespace) {
|
||||
try {
|
||||
const applications = await this.KubernetesApplicationService.get(namespace);
|
||||
const stacks = _.map(applications, (item) => item.StackName);
|
||||
return _.uniq(_.without(stacks, '-'));
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
get(namespace) {
|
||||
|
|
|
@ -20,16 +20,11 @@ class KubernetesVolumeService {
|
|||
* GET
|
||||
*/
|
||||
async getAsync(namespace, name) {
|
||||
try {
|
||||
const [pvc, pool] = await Promise.all([this.KubernetesPersistentVolumeClaimService.get(namespace, name), this.KubernetesResourcePoolService.get(namespace)]);
|
||||
return KubernetesVolumeConverter.pvcToVolume(pvc, pool);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async getAllAsync(namespace) {
|
||||
try {
|
||||
const data = await this.KubernetesResourcePoolService.get(namespace);
|
||||
const pools = data instanceof Array ? data : [data];
|
||||
const res = await Promise.all(
|
||||
|
@ -39,9 +34,6 @@ class KubernetesVolumeService {
|
|||
})
|
||||
);
|
||||
return _.flatten(res);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
get(namespace, name) {
|
||||
|
@ -55,11 +47,7 @@ class KubernetesVolumeService {
|
|||
* DELETE
|
||||
*/
|
||||
async deleteAsync(volume) {
|
||||
try {
|
||||
await this.KubernetesPersistentVolumeClaimService.delete(volume.PersistentVolumeClaim);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
delete(volume) {
|
||||
|
|
|
@ -77,7 +77,6 @@ angular.module('portainer.app').factory('AccessService', [
|
|||
}
|
||||
|
||||
async function accessesAsync(entity, parent) {
|
||||
try {
|
||||
if (!entity) {
|
||||
throw new Error('Unable to retrieve accesses');
|
||||
}
|
||||
|
@ -94,9 +93,6 @@ angular.module('portainer.app').factory('AccessService', [
|
|||
parent.TeamAccessPolicies = {};
|
||||
}
|
||||
return await getAccesses(entity.UserAccessPolicies, entity.TeamAccessPolicies, parent ? parent.UserAccessPolicies : {}, parent ? parent.TeamAccessPolicies : {});
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
function accesses(entity, parent) {
|
||||
|
|
|
@ -119,10 +119,10 @@
|
|||
"cssnano": "^3.10.0",
|
||||
"cypress": "^5.2.0",
|
||||
"cypress-wait-until": "^1.7.1",
|
||||
"eslint": "5.16.0",
|
||||
"eslint-config-prettier": "^6.10.1",
|
||||
"eslint-loader": "^2.1.2",
|
||||
"eslint-plugin-import": "^2.20.2",
|
||||
"eslint": "^7.24.0",
|
||||
"eslint-config-prettier": "^8.2.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-webpack-plugin": "^2.5.3",
|
||||
"file-loader": "^1.1.11",
|
||||
"grunt": "^1.1.0",
|
||||
"grunt-cli": "^1.3.2",
|
||||
|
|
|
@ -6,6 +6,8 @@ const CleanTerminalPlugin = require('clean-terminal-webpack-plugin');
|
|||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
|
||||
const ESLintPlugin = require('eslint-webpack-plugin');
|
||||
|
||||
const pkg = require('../package.json');
|
||||
const projectRoot = path.resolve(__dirname, '..');
|
||||
|
||||
|
@ -37,14 +39,7 @@ module.exports = {
|
|||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
'babel-loader',
|
||||
'auto-ngtemplate-loader',
|
||||
{
|
||||
// enforce: 'pre',
|
||||
loader: 'eslint-loader',
|
||||
},
|
||||
],
|
||||
use: ['babel-loader', 'auto-ngtemplate-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.html$/,
|
||||
|
@ -81,6 +76,7 @@ module.exports = {
|
|||
writeToDisk: true,
|
||||
},
|
||||
plugins: [
|
||||
new ESLintPlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
template: './app/index.html',
|
||||
templateParameters: {
|
||||
|
|
Loading…
Reference in New Issue