mirror of
https://github.com/portainer/portainer.git
synced 2025-08-09 15:55:23 +02:00
feat(registries): remove registry extension (#4155)
* feat(registries): remove client extension code * feat(registry): remove server registry code * refactor(registry): remove extension related code * feat(extensions): remove registry extension type
This commit is contained in:
parent
7e90bf11b7
commit
82064152ec
51 changed files with 13 additions and 2377 deletions
|
@ -66,21 +66,6 @@
|
|||
</td>
|
||||
<td>
|
||||
<a ui-sref="portainer.registries.registry.access({id: item.Id})" ng-if="$ctrl.accessManagement"> <i class="fa fa-users" aria-hidden="true"></i> Manage access </a>
|
||||
<a ui-sref="portainer.registries.registry.repositories({id: item.Id})" ng-if="$ctrl.registryManagement && $ctrl.canBrowse(item)" class="space-left">
|
||||
<i class="fa fa-search" aria-hidden="true"></i> Browse
|
||||
</a>
|
||||
<a
|
||||
ui-sref="portainer.extensions.extension({id: 1})"
|
||||
ng-if="!$ctrl.registryManagement && $ctrl.canBrowse(item)"
|
||||
class="space-left"
|
||||
style="color: #767676;"
|
||||
tooltip-append-to-body="true"
|
||||
tooltip-placement="bottom"
|
||||
tooltip-class="portainer-tooltip"
|
||||
uib-tooltip="Feature available via an extension"
|
||||
>
|
||||
<i class="fa fa-search" aria-hidden="true"></i> Browse (extension)
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-if="!$ctrl.dataset">
|
||||
|
|
|
@ -10,7 +10,6 @@ angular.module('portainer.app').component('registriesDatatable', {
|
|||
reverseOrder: '<',
|
||||
accessManagement: '<',
|
||||
removeAction: '<',
|
||||
registryManagement: '<',
|
||||
canBrowse: '<',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -8,10 +8,6 @@
|
|||
For information on how to generate a Gitlab Personal Access Token, follow the
|
||||
<a href="https://gitlab.com/help/user/profile/personal_access_tokens.md" target="_blank">gitlab guide</a>.
|
||||
</p>
|
||||
<p>
|
||||
<i class="fa fa-exclamation-circle orange-icon" aria-hidden="true" style="margin-right: 2px;"></i> You must provide a token with <code>api</code> scope. Failure to do so
|
||||
will mean you can only push/pull from your registry but not manage it using the <a ui-sref="portainer.extensions.extension({id: 1})">registry management (extension)</a>.
|
||||
</p>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-sm-12 form-section-title">
|
||||
|
|
8
app/portainer/models/gitlabRegistry.js
Normal file
8
app/portainer/models/gitlabRegistry.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
export function RegistryGitlabProject(project) {
|
||||
this.Id = project.id;
|
||||
this.Description = project.description;
|
||||
this.Name = project.name;
|
||||
this.Namespace = project.namespace ? project.namespace.name : '';
|
||||
this.PathWithNamespace = project.path_with_namespace;
|
||||
this.RegistryEnabled = project.container_registry_enabled;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash-es';
|
||||
import { RegistryTypes } from 'Extensions/registry-management/models/registryTypes';
|
||||
import { RegistryTypes } from '@/portainer/models/registryTypes';
|
||||
|
||||
export function RegistryViewModel(data) {
|
||||
this.Id = data.Id;
|
||||
|
|
16
app/portainer/models/registryRepository.js
Normal file
16
app/portainer/models/registryRepository.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
import _ from 'lodash-es';
|
||||
|
||||
export function RegistryRepositoryViewModel(item) {
|
||||
if (item.name && item.tags) {
|
||||
this.Name = item.name;
|
||||
this.TagsCount = _.without(item.tags, null).length;
|
||||
} else {
|
||||
this.Name = item;
|
||||
this.TagsCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
export function RegistryRepositoryGitlabViewModel(data) {
|
||||
this.Name = data.path;
|
||||
this.TagsCount = data.tags.length;
|
||||
}
|
6
app/portainer/models/registryTypes.js
Normal file
6
app/portainer/models/registryTypes.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
export const RegistryTypes = Object.freeze({
|
||||
QUAY: 1,
|
||||
AZURE: 2,
|
||||
CUSTOM: 3,
|
||||
GITLAB: 4,
|
||||
});
|
38
app/portainer/rest/gitlab.js
Normal file
38
app/portainer/rest/gitlab.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
import gitlabResponseGetLink from './transform/gitlabResponseGetLink';
|
||||
|
||||
angular.module('portainer.app').factory('Gitlab', [
|
||||
'$resource',
|
||||
'API_ENDPOINT_REGISTRIES',
|
||||
function GitlabFactory($resource, API_ENDPOINT_REGISTRIES) {
|
||||
'use strict';
|
||||
return function (env) {
|
||||
const headers = {};
|
||||
if (env) {
|
||||
headers['Private-Token'] = env.token;
|
||||
headers['X-Gitlab-Domain'] = env.url;
|
||||
}
|
||||
|
||||
const baseUrl = API_ENDPOINT_REGISTRIES + '/:id/proxies/gitlab/api/v4/projects';
|
||||
|
||||
return $resource(
|
||||
baseUrl,
|
||||
{ id: '@id' },
|
||||
{
|
||||
projects: {
|
||||
method: 'GET',
|
||||
params: { membership: 'true' },
|
||||
transformResponse: gitlabResponseGetLink,
|
||||
headers: headers,
|
||||
},
|
||||
repositories: {
|
||||
method: 'GET',
|
||||
url: baseUrl + '/:projectId/registry/repositories',
|
||||
params: { tags: true },
|
||||
headers: headers,
|
||||
transformResponse: gitlabResponseGetLink,
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
},
|
||||
]);
|
10
app/portainer/rest/transform/gitlabResponseGetLink.js
Normal file
10
app/portainer/rest/transform/gitlabResponseGetLink.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
export default function gitlabResponseGetLink(data, headers) {
|
||||
let response = {};
|
||||
try {
|
||||
response.data = angular.fromJson(data);
|
||||
response.next = headers('X-Next-Page');
|
||||
} catch (error) {
|
||||
response = data;
|
||||
}
|
||||
return response;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import _ from 'lodash-es';
|
||||
import { PorImageRegistryModel } from 'Docker/models/porImageRegistry';
|
||||
import { RegistryTypes } from 'Extensions/registry-management/models/registryTypes';
|
||||
import { RegistryTypes } from '@/portainer/models/registryTypes';
|
||||
import { RegistryCreateRequest, RegistryViewModel } from '../../models/registry';
|
||||
|
||||
angular.module('portainer.app').factory('RegistryService', [
|
||||
|
|
87
app/portainer/services/registryGitlabService.js
Normal file
87
app/portainer/services/registryGitlabService.js
Normal file
|
@ -0,0 +1,87 @@
|
|||
import _ from 'lodash-es';
|
||||
import { RegistryGitlabProject } from '../models/gitlabRegistry';
|
||||
import { RegistryRepositoryGitlabViewModel } from '../models/registryRepository';
|
||||
|
||||
angular.module('portainer.app').factory('RegistryGitlabService', [
|
||||
'$async',
|
||||
'Gitlab',
|
||||
function RegistryGitlabServiceFactory($async, Gitlab) {
|
||||
'use strict';
|
||||
var service = {};
|
||||
|
||||
/**
|
||||
* PROJECTS
|
||||
*/
|
||||
|
||||
async function _getProjectsPage(env, params, projects) {
|
||||
const response = await Gitlab(env).projects(params).$promise;
|
||||
projects = _.concat(projects, response.data);
|
||||
if (response.next) {
|
||||
params.page = response.next;
|
||||
projects = await _getProjectsPage(env, params, projects);
|
||||
}
|
||||
return projects;
|
||||
}
|
||||
|
||||
async function projectsAsync(url, token) {
|
||||
try {
|
||||
const data = await _getProjectsPage({ url: url, token: token }, { page: 1 }, []);
|
||||
return _.map(data, (project) => new RegistryGitlabProject(project));
|
||||
} catch (error) {
|
||||
throw { msg: 'Unable to retrieve projects', err: error };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* END PROJECTS
|
||||
*/
|
||||
|
||||
/**
|
||||
* REPOSITORIES
|
||||
*/
|
||||
|
||||
async function _getRepositoriesPage(params, repositories) {
|
||||
const response = await Gitlab().repositories(params).$promise;
|
||||
repositories = _.concat(repositories, response.data);
|
||||
if (response.next) {
|
||||
params.page = response.next;
|
||||
repositories = await _getRepositoriesPage(params, repositories);
|
||||
}
|
||||
return repositories;
|
||||
}
|
||||
|
||||
async function repositoriesAsync(registry) {
|
||||
try {
|
||||
const params = {
|
||||
id: registry.Id,
|
||||
projectId: registry.Gitlab.ProjectId,
|
||||
page: 1,
|
||||
};
|
||||
const data = await _getRepositoriesPage(params, []);
|
||||
return _.map(data, (r) => new RegistryRepositoryGitlabViewModel(r));
|
||||
} catch (error) {
|
||||
throw { msg: 'Unable to retrieve repositories', err: error };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* END REPOSITORIES
|
||||
*/
|
||||
|
||||
/**
|
||||
* SERVICE FUNCTIONS DECLARATION
|
||||
*/
|
||||
|
||||
function projects(url, token) {
|
||||
return $async(projectsAsync, url, token);
|
||||
}
|
||||
|
||||
function repositories(registry) {
|
||||
return $async(repositoriesAsync, registry);
|
||||
}
|
||||
|
||||
service.projects = projects;
|
||||
service.repositories = repositories;
|
||||
return service;
|
||||
},
|
||||
]);
|
|
@ -1,4 +1,4 @@
|
|||
import { RegistryTypes } from 'Extensions/registry-management/models/registryTypes';
|
||||
import { RegistryTypes } from '@/portainer/models/registryTypes';
|
||||
import { RegistryDefaultModel } from '../../../models/registry';
|
||||
|
||||
angular.module('portainer.app').controller('CreateRegistryController', [
|
||||
|
@ -7,8 +7,7 @@ angular.module('portainer.app').controller('CreateRegistryController', [
|
|||
'RegistryService',
|
||||
'Notifications',
|
||||
'RegistryGitlabService',
|
||||
'ExtensionService',
|
||||
function ($scope, $state, RegistryService, Notifications, RegistryGitlabService, ExtensionService) {
|
||||
function ($scope, $state, RegistryService, Notifications, RegistryGitlabService) {
|
||||
$scope.selectQuayRegistry = selectQuayRegistry;
|
||||
$scope.selectAzureRegistry = selectAzureRegistry;
|
||||
$scope.selectCustomRegistry = selectCustomRegistry;
|
||||
|
@ -106,7 +105,6 @@ angular.module('portainer.app').controller('CreateRegistryController', [
|
|||
function initView() {
|
||||
$scope.RegistryTypes = RegistryTypes;
|
||||
$scope.model = new RegistryDefaultModel();
|
||||
ExtensionService.extensionEnabled(ExtensionService.EXTENSIONS.REGISTRY_MANAGEMENT).then((data) => ($scope.registryExtensionEnabled = data));
|
||||
}
|
||||
|
||||
initView();
|
||||
|
|
|
@ -81,7 +81,6 @@
|
|||
order-by="Name"
|
||||
access-management="isAdmin"
|
||||
remove-action="removeAction"
|
||||
registry-management="registryManagementAvailable"
|
||||
can-browse="canBrowse"
|
||||
></registries-datatable>
|
||||
</div>
|
||||
|
|
|
@ -8,9 +8,8 @@ angular.module('portainer.app').controller('RegistriesController', [
|
|||
'DockerHubService',
|
||||
'ModalService',
|
||||
'Notifications',
|
||||
'ExtensionService',
|
||||
'Authentication',
|
||||
function ($q, $scope, $state, RegistryService, DockerHubService, ModalService, Notifications, ExtensionService, Authentication) {
|
||||
function ($q, $scope, $state, RegistryService, DockerHubService, ModalService, Notifications, Authentication) {
|
||||
$scope.state = {
|
||||
actionInProgress: false,
|
||||
};
|
||||
|
@ -75,12 +74,10 @@ angular.module('portainer.app').controller('RegistriesController', [
|
|||
$q.all({
|
||||
registries: RegistryService.registries(),
|
||||
dockerhub: DockerHubService.dockerhub(),
|
||||
registryManagement: ExtensionService.extensionEnabled(ExtensionService.EXTENSIONS.REGISTRY_MANAGEMENT),
|
||||
})
|
||||
.then(function success(data) {
|
||||
$scope.registries = data.registries;
|
||||
$scope.dockerhub = data.dockerhub;
|
||||
$scope.registryManagementAvailable = data.registryManagement;
|
||||
$scope.isAdmin = Authentication.isAdmin();
|
||||
})
|
||||
.catch(function error(err) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue