2020-04-10 21:54:53 +00:00
|
|
|
import gitlabResponseGetLink from './transform/gitlabResponseGetLink';
|
2019-11-12 03:28:31 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
angular.module('portainer.extensions.registrymanagement').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;
|
|
|
|
}
|
2019-11-12 03:28:31 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
const baseUrl = API_ENDPOINT_REGISTRIES + '/:id/proxies/gitlab/api/v4/projects';
|
2019-11-12 03:28:31 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
},
|
|
|
|
]);
|