mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
chore(project): add prettier for code format (#3645)
* chore(project): install prettier and lint-staged * chore(project): apply prettier to html too * chore(project): git ignore eslintcache * chore(project): add a comment about format script * chore(prettier): update printWidth * chore(prettier): remove useTabs option * chore(prettier): add HTML validation * refactor(prettier): fix closing tags * feat(prettier): define angular parser for html templates * style(prettier): run prettier on codebase Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
This commit is contained in:
parent
6663073be1
commit
cf5056d9c0
714 changed files with 31228 additions and 28305 deletions
|
@ -1,72 +1,73 @@
|
|||
import _ from 'lodash-es';
|
||||
import { RegistryTypes } from 'Extensions/registry-management/models/registryTypes';
|
||||
|
||||
angular.module('portainer.docker')
|
||||
.factory('ImageHelper', [function ImageHelperFactory() {
|
||||
'use strict';
|
||||
angular.module('portainer.docker').factory('ImageHelper', [
|
||||
function ImageHelperFactory() {
|
||||
'use strict';
|
||||
|
||||
var helper = {};
|
||||
var helper = {};
|
||||
|
||||
helper.isValidTag = isValidTag;
|
||||
helper.createImageConfigForContainer = createImageConfigForContainer;
|
||||
helper.getImagesNamesForDownload = getImagesNamesForDownload;
|
||||
helper.removeDigestFromRepository = removeDigestFromRepository;
|
||||
helper.imageContainsURL = imageContainsURL;
|
||||
helper.isValidTag = isValidTag;
|
||||
helper.createImageConfigForContainer = createImageConfigForContainer;
|
||||
helper.getImagesNamesForDownload = getImagesNamesForDownload;
|
||||
helper.removeDigestFromRepository = removeDigestFromRepository;
|
||||
helper.imageContainsURL = imageContainsURL;
|
||||
|
||||
function isValidTag(tag) {
|
||||
return tag.match(/^(?![\.\-])([a-zA-Z0-9\_\.\-])+$/g);
|
||||
}
|
||||
function isValidTag(tag) {
|
||||
return tag.match(/^(?![\.\-])([a-zA-Z0-9\_\.\-])+$/g);
|
||||
}
|
||||
|
||||
function getImagesNamesForDownload(images) {
|
||||
var names = images.map(function(image) {
|
||||
return image.RepoTags[0] !== '<none>:<none>' ? image.RepoTags[0] : image.Id;
|
||||
});
|
||||
return {
|
||||
names: names
|
||||
};
|
||||
}
|
||||
function getImagesNamesForDownload(images) {
|
||||
var names = images.map(function (image) {
|
||||
return image.RepoTags[0] !== '<none>:<none>' ? image.RepoTags[0] : image.Id;
|
||||
});
|
||||
return {
|
||||
names: names,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {PorImageRegistryModel} registry
|
||||
*/
|
||||
function createImageConfigForContainer(registry) {
|
||||
const data = {
|
||||
fromImage: ''
|
||||
};
|
||||
let fullImageName = '';
|
||||
/**
|
||||
*
|
||||
* @param {PorImageRegistryModel} registry
|
||||
*/
|
||||
function createImageConfigForContainer(registry) {
|
||||
const data = {
|
||||
fromImage: '',
|
||||
};
|
||||
let fullImageName = '';
|
||||
|
||||
if (registry.UseRegistry) {
|
||||
if (registry.Registry.Type === RegistryTypes.GITLAB) {
|
||||
const slash = _.startsWith(registry.Image, ':') ? '' : '/';
|
||||
fullImageName = registry.Registry.URL + '/' + registry.Registry.Gitlab.ProjectPath + slash + registry.Image;
|
||||
if (registry.UseRegistry) {
|
||||
if (registry.Registry.Type === RegistryTypes.GITLAB) {
|
||||
const slash = _.startsWith(registry.Image, ':') ? '' : '/';
|
||||
fullImageName = registry.Registry.URL + '/' + registry.Registry.Gitlab.ProjectPath + slash + registry.Image;
|
||||
} else {
|
||||
const url = registry.Registry.URL ? registry.Registry.URL + '/' : '';
|
||||
fullImageName = url + registry.Image;
|
||||
}
|
||||
if (!_.includes(registry.Image, ':')) {
|
||||
fullImageName += ':latest';
|
||||
}
|
||||
} else {
|
||||
const url = registry.Registry.URL ? registry.Registry.URL + '/' : '';
|
||||
fullImageName = url + registry.Image;
|
||||
fullImageName = registry.Image;
|
||||
}
|
||||
if (!_.includes(registry.Image, ':')) {
|
||||
fullImageName += ':latest';
|
||||
}
|
||||
} else {
|
||||
fullImageName = registry.Image;
|
||||
|
||||
data.fromImage = fullImageName;
|
||||
return data;
|
||||
}
|
||||
|
||||
data.fromImage = fullImageName;
|
||||
return data;
|
||||
}
|
||||
|
||||
function imageContainsURL(image) {
|
||||
const split = _.split(image, '/');
|
||||
const url = split[0];
|
||||
if (split.length > 1) {
|
||||
return _.includes(url, '.') || _.includes(url, ':');
|
||||
function imageContainsURL(image) {
|
||||
const split = _.split(image, '/');
|
||||
const url = split[0];
|
||||
if (split.length > 1) {
|
||||
return _.includes(url, '.') || _.includes(url, ':');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function removeDigestFromRepository(repository) {
|
||||
return repository.split('@sha')[0];
|
||||
}
|
||||
function removeDigestFromRepository(repository) {
|
||||
return repository.split('@sha')[0];
|
||||
}
|
||||
|
||||
return helper;
|
||||
}]);
|
||||
return helper;
|
||||
},
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue