import { ImageBuildModel } from "../models/image";
angular.module('portainer.docker')
.factory('BuildService', ['$q', 'Build', 'FileUploadService', function BuildServiceFactory($q, Build, FileUploadService) {
'use strict';
var service = {};
service.buildImageFromUpload = function(names, file, path) {
var deferred = $q.defer();
FileUploadService.buildImage(names, file, path)
.then(function success(response) {
var model = new ImageBuildModel(response.data);
deferred.resolve(model);
})
.catch(function error(err) {
deferred.reject(err);
});
return deferred.promise;
};
service.buildImageFromURL = function(names, url, path) {
var params = {
t: names,
remote: url,
dockerfile: path
Build.buildImage(params, {}).$promise
.then(function success(data) {
var model = new ImageBuildModel(data);
service.buildImageFromDockerfileContent = function(names, content) {
t: names
var payload = {
content: content
Build.buildImageOverride(params, payload).$promise
return service;
}]);