blob: 972023cd579bf9b7c020239982d8784c028ef45c [file] [log] [blame]
Matteo Scandoloba678a92016-06-20 17:16:15 -07001/**
2 * © OpenCORD
3 *
4 * Visit http://guide.xosproject.org/devguide/addview/ for more information
5 *
6 * Created by teone on 6/22/16.
7 */
8
9(function () {
10 'use strict';
11
12 /**
13 * @ngdoc service
14 * @name xos.ImageEncoder.serviceGrid
15 **/
16
17 // TODO write tests
18 angular.module('xos.serviceGrid')
19 .service('ImageEncoder', function($q, Images){
20
21 this.buildTosca = (imageId, toscaSpec) => {
22 const d = $q.defer();
23
24 Images.get({id: imageId}).$promise
25 .then(image => {
26 const toscaObj = {};
27 toscaObj[`image#${image.name}`] = {
28 type: 'tosca.nodes.Image'
29 };
30 angular.extend(toscaSpec.topology_template.node_templates, toscaObj);
31 d.resolve([toscaSpec, image]);
32 })
33 .catch(d.reject);
34
35
36 return d.promise;
37 };
38 });
39})();
40