Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

loopback-bluemix

Package Overview
Dependencies
Maintainers
20
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loopback-bluemix - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

yarn.lock

13

CHANGES.md

@@ -0,3 +1,16 @@

2017-06-23, Version 2.2.0
=========================
* Support IBM Object Storage (Hage Yaapa)
* Provision Bluemix data services (Hage Yaapa)
* Fix version number (Tetsuo Seto)
2017-05-23, Version 2.1.0
=========================
2017-05-23, Version 1.2.0

@@ -4,0 +17,0 @@ =========================

41

lib/cf.js

@@ -445,8 +445,8 @@ // Copyright IBM Corp. 2017. All Rights Reserved.

}
var tag = 'data_management';
getServiceInstances(parent, accessToken, options, function(err, instances) {
if (err) return cb(err);
var dbs = instances.filter(function(i) {
var tags = i.service.entity.tags || [];
return tags.indexOf(tag) !== -1;
var serviceName = i.service.entity.label;
return bluemixSupportedServiceLabels.indexOf(serviceName) !== -1;
});

@@ -465,21 +465,28 @@ cb(null, dbs);

function getSupportedServices(parent, accessToken, options, cb) {
if (typeof options === 'function' && cb === undefined) {
if (typeof options === 'function') {
cb = options;
options = {};
}
getServices(parent, accessToken, options, function(err, services) {
if (err) return cb(err);
var supportedServices = {};
services.forEach(function(resource) {
var label = resource.entity.label;
if (bluemixSupportedServiceLabels.indexOf(label) > -1) {
supportedServices[label] = {};
var service = supportedServices[label];
service.guid = resource.metadata.guid;
service.url = resource.metadata.url;
service.plansUrl = resource.entity['service_plans_url'];
var services = [];
var supportedServices = [];
function getMarketplace(url) {
return invokeResource(url, accessToken, options, function(err, res) {
if (err) return cb(err);
services = services.concat(res.body.resources);
if (res.body.next_url) {
getMarketplace(res.body.next_url);
} else {
services.forEach(function(service) {
if (bluemixSupportedServiceLabels.indexOf(service.entity.label) > -1) {
supportedServices.push(service.entity);
}
});
cb(null, supportedServices);
}
});
cb(null, supportedServices);
});
}
var cfConfig = getCfConfig();
var url = '/v2/spaces/' + cfConfig.space.guid + '/services';
return getMarketplace(url);
}

@@ -486,0 +493,0 @@

@@ -33,3 +33,2 @@ // Copyright IBM Corp. 2017. All Rights Reserved.

datasource.log('No Bluemix data service instances found.');
return done();
}

@@ -47,4 +46,4 @@ var serviceChoices = [];

.keys(existingBluemixDatasources);
if (existingBluemixDatasourcesKeys.length > 1) {
datasource.log('\n Already added:\n');
if (existingBluemixDatasourcesKeys.length > 0) {
datasource.log('\n Already added:');
existingBluemixDatasourcesKeys.forEach(function(name) {

@@ -57,5 +56,4 @@ if (name !== 'db') {

if (existingBluemixDatasourcesKeys.length === resources.length) {
if (resources.length && existingBluemixDatasourcesKeys.length === resources.length) {
datasource.log('All datasource services already added.');
return done();
}

@@ -87,4 +85,3 @@ var services = {};

// TODO: uncomment to enable data service provisioning
// serviceChoices.push('Provision a new service ▶︎');
serviceChoices.push('Provision a new service ▶︎');

@@ -94,3 +91,3 @@ var prompts = [

name: 'serviceName',
message: globalize.f('Select the Bluemix datasource service'),
message: globalize.f('Select the Bluemix datasource option'),
type: 'list',

@@ -123,4 +120,7 @@ choices: serviceChoices,

var serviceTypes = [];
var connectorNameLookup = {};
Object.keys(bluemixSupportedServices).forEach(function(k) {
serviceTypes.push(bluemixSupportedServices[k]);
var label = bluemixSupportedServices[k].label;
serviceTypes.push(label);
connectorNameLookup[label] = k;
});

@@ -140,4 +140,5 @@ var prompts = [

return datasource.prompt(prompts).then(function(answers) {
datasource.serviceName = answers.serviceName;
datasource.name = answers.serviceName;
datasource.serviceType = answers.serviceType;
datasource.connector = connectorNameLookup[answers.serviceType];
return done();

@@ -153,5 +154,9 @@ }.bind(datasource));

var done = datasource.async();
console.log(' Getting service plans...');
cf.getSupportedServices(null, datasource.accessToken, function(err, serviceDetails) {
if (err) return done(err);
datasource.dataServices = serviceDetails;
datasource.dataServices = {};
serviceDetails.forEach(function(service) {
datasource.dataServices[service.label] = service;
});
return done();

@@ -170,5 +175,6 @@ });

datasource.servicePlans = {};
cf.getServicePlans(null, datasource.accessToken, service.plansUrl,
function(err, servicePlans) {
cf.getResource(service.service_plans_url, datasource.accessToken, {},
function(err, res) {
if (err) return done(err);
var servicePlans = res.body.resources;
servicePlans.forEach(function(plan) {

@@ -197,10 +203,12 @@ datasource.servicePlans[plan.entity.name] = plan.metadata.guid;

];
var cfConfig = cf.getCfConfig();
return datasource.prompt(prompts).then(function(answers) {
var details = {};
details.name = datasource.serviceName;
details.name = datasource.name;
details['service_plan_guid'] = datasource.servicePlans[answers.servicePlan];
details['space_guid'] = datasource.space.guid;
cf.provisionService(datasource.accessToken, details, function(err, res, service) {
details['space_guid'] = cfConfig.space.guid;
cf.provisionService(datasource.accessToken, details, function(err, res) {
if (err) return done(err);
datasource.serviceGUID = service.metadata.guid;
var service = res.body;
datasource.serviceGuid = service.metadata.guid;
return done();

@@ -226,3 +234,3 @@ });

'app_guid': app.metadata.guid,
'service_instance_guid': datasource.serviceGUID,
'service_instance_guid': datasource.serviceGuid,
};

@@ -229,0 +237,0 @@ cf.bindService(datasource.accessToken, details, function(err) {

{
"name": "loopback-bluemix",
"version": "2.1.0",
"version": "2.2.0",
"description": "Utilities for generating generate Bluemix artefacts",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -11,2 +11,16 @@ # loopback-bluemix

## Testing
Before testing:
```
npm run create-bm-fixtures
```
To delete the fixtures:
```
npm run delete-bm-fixtures
```
## API

@@ -13,0 +27,0 @@

@@ -9,4 +9,7 @@ {

"label": "compose-for-mongodb"
},
"ibm-object-storage": {
"label": "Object-Storage"
}
}
}

@@ -27,26 +27,49 @@ 'use strict';

var credentials = service.credentials;
dataSources[service.name] = {
name: service.name,
connector: configuredDatasource.connector,
url: credentials.uri || credentials.url,
host: credentials.host,
port: credentials.port,
username: credentials.username,
password: credentials.password,
};
var dataSource = dataSources[service.name];
if ('database' in configuredDatasource) {
dataSource.database = configuredDatasource.database;
}
if ('db' in configuredDatasource) {
dataSource.db = configuredDatasource.db;
}
if (service.label === 'Object-Storage') {
// Connectors that are implemented by loopback-component-storage
var loopbackComponentStorageConnectors = ['ibm-object-storage'];
if (credentials.db_type === 'redis') {
dataSource.url += '/' + configuredDatasource.database;
} else if (credentials.db_type === 'mysql' ||
credentials.db_type === 'postgresql') {
dataSource.url = dataSource.url.replace('compose',
configuredDatasource.database);
dataSources[service.name] = {
name: service.name,
provider: 'openstack',
useServiceCatalog: true,
useInternal: false,
keystoneAuthVersion: 'v3',
authUrl: credentials.auth_url,
tenantId: credentials.projectId,
domainId: credentials.domainId,
username: credentials.username,
password: credentials.password,
region: credentials.region,
connector: loopbackComponentStorageConnectors
.indexOf(configuredDatasource.connector) > -1 ?
'loopback-component-storage' : configuredDatasource.connector,
};
} else {
dataSources[service.name] = {
name: service.name,
connector: configuredDatasource.connector,
url: credentials.uri || credentials.url,
host: credentials.host,
port: credentials.port,
username: credentials.username,
password: credentials.password,
};
var dataSource = dataSources[service.name];
if ('database' in configuredDatasource) {
dataSource.database = configuredDatasource.database;
}
if ('db' in configuredDatasource) {
dataSource.db = configuredDatasource.db;
}
if (credentials.db_type === 'redis') {
dataSource.url += '/' + configuredDatasource.database;
} else if (credentials.db_type === 'mysql' ||
credentials.db_type === 'postgresql') {
dataSource.url = dataSource.url.replace('compose',
configuredDatasource.database);
}
}

@@ -53,0 +76,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc