Skip to content

Commit

Permalink
327527413 Replace apigeetool with volos-util-apigee
Browse files Browse the repository at this point in the history
  • Loading branch information
tapasthakkar authored and keyurkarnik committed Apr 16, 2024
1 parent c60febb commit 855459a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 124 deletions.
20 changes: 0 additions & 20 deletions cli/lib/cert.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ const edgeconfig = require('microgateway-config');
const util = require('util');
const configLocations = require('../../config/locations');
const assert = require('assert')
//const prompt = require('cli-prompt');
//const path = require('path');
//const apigeetool = require('apigeetool');
//const _ = require('lodash');
//const async = require('async');
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;
edgeconfig.setConsoleLogger(writeConsoleLog);

Expand Down Expand Up @@ -142,18 +137,3 @@ Cert.prototype.retrievePublicKeyPrivate = function(options) {
writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP}, certificate);
})
}

/*
function optionError(message) {
writeConsoleLog('error',{component: CONSOLE_LOG_TAG_COMP},message);
this.help();
}
function printError(err) {
if (err.response) {
writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},err.response.error);
} else {
writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},err);
}
}
*/
4 changes: 0 additions & 4 deletions cli/lib/configure.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
'use strict';

const edgeconfig = require('microgateway-config')
//const prompt = require('cli-prompt');
//const path = require('path');
//const apigeetool = require('apigeetool');
//const _ = require('lodash');
const async = require('async')
const util = require('util')
const fs = require('fs')
Expand Down
103 changes: 5 additions & 98 deletions cli/lib/deploy-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
const tmp = require('tmp');
const cpr = require('cpr');
const rimraf = require('rimraf');
const apigeetool = require('apigeetool');
//const request = require('postman-request');
const apigeeUtils = require('volos-util-apigee');
const assert = require('assert');
const path = require('path');
const async = require('async')
Expand All @@ -13,17 +12,13 @@ const xml2js = require("xml2js");
const parseString = xml2js.parseString;

const DEFAULT_HOSTS = 'default,secure';
//const url = require('url');
const debug = require('debug')('edgemicro-auth')
//const _ = require('lodash')
var exec = require('child_process').exec;
const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog;

const CONSOLE_LOG_TAG_COMP = 'microgateway deploy auth';

var run = function(cmd, cb) {
//writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},'run %s',cmd)
// var child =
exec(cmd, {
maxBuffer: 1024 * 500
}, function(error /*, stdout, stderr */) {
Expand Down Expand Up @@ -64,7 +59,7 @@ Deployment.prototype.deployEdgeMicroInternalProxy = function deployEdgeMicroInte
opts.password = options.password;
}

apigeetool.deployProxy(opts, function(err, res) {
apigeeUtils.deployProxy(opts, function(err, res) {
if (err) {
return callback(err);
}
Expand Down Expand Up @@ -148,7 +143,7 @@ Deployment.prototype.checkDeployedInternalProxies = function checkDeployedIntern
opts.password = options.password;
}
// const that = this;
apigeetool.listDeployments(opts, function(err /*, proxies */) {
apigeeUtils.listDeployments(opts, function(err /*, proxies */) {
if (err) {
if (err.message.includes("404")) {
return cb(null, options);
Expand Down Expand Up @@ -180,7 +175,7 @@ Deployment.prototype.checkDeployedProxies = function checkDeployedProxies(option
opts.password = options.password;
}
//const that = this;
apigeetool.listDeployments(opts, function(err /*, proxies */) {
apigeeUtils.listDeployments(opts, function(err /*, proxies */) {
if (err) {
if (err.message.includes("404")) {
return cb(null, options);
Expand Down Expand Up @@ -332,7 +327,7 @@ Deployment.prototype.deployProxyWithPassword = function deployProxyWithPassword(
setEdgeMicroInternalEndpoint(dir + "/apiproxy/policies/Authenticate-Call.xml", options.runtimeUrl);
}
writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},'Give me a minute or two... this can take a while...');
apigeetool.deployProxy(opts, function(err) {
apigeeUtils.deployProxy(opts, function(err) {
if (err) {
if (err.code === 'ECONNRESET' && err.message === 'socket hang up') {
err.message = 'Deployment timeout. Please try again or use the --upload option.'
Expand All @@ -345,94 +340,6 @@ Deployment.prototype.deployProxyWithPassword = function deployProxyWithPassword(
writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},'App %s deployed.', options.proxyName);
callback(null, options.runtimeUrl ? authUri + '/publicKey' : util.format(authUri + '/publicKey', options.org, options.env));
}

//writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},'App %s added to your org. Now adding resources.', options.proxyName);
/* opts.password = options.password; // override a apigeetool side-effect bug
installJavaCallout(managementUri, opts, function(err) {
if (err) {
return callback(err);
}
writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},'App %s deployed.', options.proxyName);
callback(null, options.runtimeUrl ? authUri + '/publicKey' : util.format(authUri + '/publicKey', options.org, options.env));
});*/
});
})
}

/*
function installJavaCallout(managementUri, opts, cb) {
var jarName = 'micro-gateway-products-javacallout-1.0.0.jar';
// todo: revision?
var addResourceUri = '%s/v1/organizations/%s/apis/%s/revisions/1/resources?name=%s&type=java';
var uri = util.format(addResourceUri, managementUri, opts.organization, opts.api, jarName);
var httpReq = request({
uri: uri,
method: 'POST',
headers: {
'Content-Type': 'application/octet-stream'
},
auth: {
username: opts.username,
password: opts.password
}
}, function(err, res) {
err = translateError(err, res);
if (err) {
return cb(err);
}
var addStepDefinitionUri = '%s/v1/organizations/%s/apis/%s/revisions/1/stepdefinitions';
uri = util.format(addStepDefinitionUri, managementUri, opts.organization, opts.api);
var data = '<JavaCallout name=\'JavaCallout\'><ResourceURL>java://%s</ResourceURL><ClassName>io.apigee.microgateway.javacallout.Callout</ClassName></JavaCallout>';
request({
uri: uri,
method: 'POST',
headers: {
'Content-Type': 'application/xml'
},
auth: {
username: opts.username,
password: opts.password
},
body: util.format(data, jarName)
}, function(err) {
if (err) {
return cb(err);
}
var addStepUri = '%s/v1/organizations/%s/apis/%s/revisions/1/proxies/default/steps?name=JavaCallout&flow=PostFlow&enforcement=response';
uri = util.format(addStepUri, managementUri, opts.organization, opts.api);
request({
uri: uri,
method: 'POST',
auth: {
username: opts.username,
password: opts.password
}
}, function(err, res) {
cb(err, res)
});
});
});
var fileStream = fs.createReadStream(path.resolve(__dirname, jarName));
fileStream.pipe(httpReq);
}
function translateError(err, res) {
if (!err && res.statusCode >= 400) {
var msg = 'cannot ' + res.request.method + ' ' + url.format(res.request.uri) + ' (' + res.statusCode + ')';
err = new Error(msg);
err.text = res.body;
res.error = err;
}
return err;
}
*/
1 change: 0 additions & 1 deletion cli/lib/private.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const fs = require('fs');
const path = require('path');
//const apigeetool = require('apigeetool');
const util = require('util');
const url = require('url');
const request = require('postman-request');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"edgemicro": "./cli/edgemicro"
},
"dependencies": {
"apigeetool": "^0.16.1",
"async": "^2.6.4",
"body-parser": "^1.19.0",
"cli-prompt": "^0.5.0",
Expand Down Expand Up @@ -36,6 +35,7 @@
"volos-cache-memory": "^0.10.1",
"volos-spikearrest-common": "^0.10.4",
"volos-spikearrest-memory": "^0.10.2",
"volos-util-apigee": "0.1.1",
"xml2js": "^0.5.0"
},
"devDependencies": {
Expand Down

0 comments on commit 855459a

Please sign in to comment.