Files
backroad/app/portainer/services/api/dockerhubService.js
2025-12-18 13:45:26 +02:00

28 lines
1.0 KiB
JavaScript

import { PortainerEndpointTypes } from '@/portainer/models/endpoint/models';
import { isLocalEnvironment } from '@/react/portainer/environments/utils';
angular.module('portainer.app').factory('DockerHubService', DockerHubService);
/* @ngInject */
function DockerHubService(Endpoints, AgentDockerhub) {
return {
checkRateLimits,
};
function checkRateLimits(endpoint, registryId) {
if (isLocalEnvironment(endpoint)) {
return Endpoints.dockerhubLimits({ id: endpoint.Id, registryId }).$promise;
}
switch (endpoint.Type) {
case PortainerEndpointTypes.AgentOnDockerEnvironment:
case PortainerEndpointTypes.EdgeAgentOnDockerEnvironment:
return AgentDockerhub.limits({ endpointId: endpoint.Id, endpointType: 'docker', registryId }).$promise;
case PortainerEndpointTypes.AgentOnKubernetesEnvironment:
case PortainerEndpointTypes.EdgeAgentOnKubernetesEnvironment:
return AgentDockerhub.limits({ endpointId: endpoint.Id, endpointType: 'kubernetes', registryId }).$promise;
}
}
}