Skip to content

Instantly share code, notes, and snippets.

@smerrill
Created April 16, 2014 23:14
Show Gist options
  • Save smerrill/10941486 to your computer and use it in GitHub Desktop.
Save smerrill/10941486 to your computer and use it in GitHub Desktop.
'use strict';
var OpenShift = require('node-openshift-client');
var util = require('util');
var qs = require('qs');
// Connect to our OpenShift Origin!
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
var openshift = new OpenShift({
username : 'smerrill',
password : 'merrill',
base_url : 'https://broker.openshift.phase2technology.com/broker/rest/'
});
util.puts('Calling createApplication.');
function app_data(options, cartridges) {
var result = qs.stringify(options);
var querystring = require('querystring');
for (var i in cartridges) {
var cart = cartridges[i];
// This is a downloadable cartridge.
if (cart.indexOf('http') === 0) {
result += '&cartridge[][url]=' + cartridges[i];
}
else {
result += '&cartridge[][name]=' + cartridges[i];
}
}
return result;
}
var app_cartridges = [
'php-5.3',
'mysql-5.5',
'cron',
'https://cartreflect-claytondev.rhcloud.com/reflect?github=smerrill/openshift-community-pressflow7'
];
var app_options = {
name : 'apitestapp',
initial_git_url : 'https://github.com/smerrill/pressflow-7-quickstart.git'
};
console.log(app_data(app_options, app_cartridges));
openshift.createApplication('smerrill',
app_data(app_options, app_cartridges),
function (error, result) {
util.print(error);
util.print(result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment