GithubHelp home page GithubHelp logo

apigee / apigeetool-node Goto Github PK

View Code? Open in Web Editor NEW
88.0 27.0 90.0 8.41 MB

"apigeetool" implementation in Node.js for managing Apigee Edge apps and proxies

License: MIT License

JavaScript 99.22% Shell 0.40% Dockerfile 0.37%

apigeetool-node's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apigeetool-node's Issues

apigeetool fails to upload proxy files (in some circumstances)

Hi all

We are using apigeetool to deploy our bundles via executing them from grunt shell.

We have 3 proxy files under /proxies folder:

  • admin.xml
  • default.xml
  • monitoring.xml

When using the latest version of apigeetool (0.6.1), we realised that none of the proxy files are imported into Apigee. Here is the full log:

Running "shell:deploy" (shell) task
deployproxy: {"debug":true,"verbose":true,"username":"email-address-for-deployment","password":{},"organization":"org-here","environments":"intg","api":"b2b-otaxml","directory":".","baseuri":"https://api.enterprise.apigee.com","asyncLimit":4}
Resolve NPM modules = false
Going to create revision 205 of API b2b-otaxml
Calling https://api.enterprise.apigee.com/v1/o/org-here/apis?action=import&validate=false&name=b2b-otaxml
Creating revision 205 of API b2b-otaxml
Uploading jsc resource AuthorizeIpAddress.js
Uploading jsc resource ConvertConfigurationToJson.js
Uploading jsc resource ExtractConfigurationVariables.js
Uploading jsc resource ExtractInvalidateCacheRequestVariables.js
Uploading jsc resource ModifyAvailabilityCacheResponse.js
Uploading jsc resource logglyDirect.js
Uploading node resource Gruntfile.js
Uploading node resource api/controllers/fitController.js
Uploading node resource api/controllers/statusController.js
Uploading node resource api/converters/availabilityConverter.js
Uploading node resource api/converters/cancellationConverter.js
Uploading node resource api/converters/fetchReservationConverter.js
Uploading node resource api/converters/reservationConverter.js
Uploading node resource api/handlers/invalidRequestHandler.js
Uploading node resource api/handlers/otaAvailabilityRequestHandler.js
Uploading node resource api/handlers/otaCancellationRequestHandler.js
Uploading node resource api/handlers/otaFetchReservationRequestHandler.js
Uploading node resource api/handlers/otaHandlers.js
Uploading node resource api/handlers/otaReservationHandler.js
Uploading node resource api/handlers/owsFetchReservationRequestHandler.js
Uploading node resource api/handlers/unacceptableRequestHandler.js
Uploading node resource api/helpers/cheerio.js
Uploading node resource api/helpers/config.js
Uploading node resource api/helpers/context.js
Uploading node resource api/helpers/librato.js
Uploading node resource api/helpers/logger.js
Uploading node resource api/helpers/loggly.js
Uploading node resource api/helpers/ows.js
Uploading node resource api/helpers/owsParams.js
Uploading node resource api/helpers/owsRequest.js
Uploading node resource api/helpers/resourceRequest.js
Uploading node resource api/helpers/template.js
Uploading node resource api/parsers/availabilityResponseParser.js
Uploading node resource api/parsers/cancellationResponseParser.js
Uploading node resource api/parsers/fetchReservationResponseParser.js
Uploading node resource api/parsers/fetchRoomResponseParser.js
Uploading node resource api/parsers/headerResponseParser.js
Uploading node resource api/parsers/otaAvailabilityRequestParser.js
Uploading node resource api/parsers/otaCancellationRequestParser.js
Uploading node resource api/parsers/otaFetchReservationRequestParser.js
Uploading node resource api/parsers/otaReservationRequestParser.js
Uploading node resource api/parsers/reservationResponseParser.js
Uploading node resource api/templates/availability.request.ows.xml
Uploading node resource api/templates/availability.response.ota.xml
Uploading node resource api/templates/cancellation.request.ows.xml
Uploading node resource api/templates/cancellation.response.ota.xml
Uploading node resource api/templates/fetch.reservation.request.ows.xml
Uploading node resource api/templates/fetch.reservation.response.ota.xml
Uploading node resource api/templates/fetchRoom.request.ows.xml
Uploading node resource api/templates/reservation.request.ows.xml
Uploading node resource api/templates/reservation.response.ota.xml
Uploading node resource api/validators/countryValidator.js
Uploading node resource api/validators/otaFetchReservationValidator.js
Uploading node resource app.js
Uploading node resource config/non-prod.json
Uploading node resource config/prod.json
Uploading node resource node_modules_apickli.zip
Uploading node resource node_modules_async.zip
Uploading node resource node_modules_builder-builder.zip
Uploading node resource node_modules_body-parser.zip
Uploading node resource node_modules_csvtojson.zip
Uploading node resource node_modules_del.zip
Uploading node resource node_modules_cheerio.zip
Uploading node resource node_modules_express.zip
Uploading node resource node_modules_i18n-iso-countries.zip
Uploading node resource node_modules_handlebars.zip
Uploading node resource node_modules_express-winston.zip
Uploading node resource node_modules_jstoxml.zip
Uploading node resource node_modules_librato-node.zip
Uploading node resource node_modules_mkdirp.zip
Uploading node resource node_modules_moment-range.zip
Uploading node resource node_modules_moment.zip
Uploading node resource node_modules_pretty-data.zip
Uploading node resource node_modules_nconf.zip
Uploading node resource node_modules_require-dir.zip
Uploading node resource node_modules_loggly.zip
Uploading node resource node_modules_shortid.zip
Uploading node resource node_modules_sinon.zip
Uploading node resource node_modules_underscore.zip
Uploading node resource node_modules_underscore.string.zip
Uploading node resource node_modules_winston.zip
Uploading node resource package.json
Uploading node resource node_modules_request.zip
Uploading node resource node_modules_winston-loggly.zip
Uploading policy AssignMessage.404.xml
Uploading policy AssignMessage.InvalidApiKeyForGivenResource.xml
Uploading policy AssignMessage.PutVariableValuesToResponseHeaders.xml
Uploading policy AssignMessage.ReturnStatusResponse.xml
Uploading policy AssignMessage.Set500ErrorVariables.xml
Uploading policy AssignMessage.SetApiKeyNotSuppliedErrorVariables.xml
Uploading policy AssignMessage.SetApigeeAuthenticationErrorVariables.xml
Uploading policy AssignMessage.SetDefaultContentType.xml
Uploading policy AssignMessage.SetIPAccessErrorVariables.xml
Uploading policy AssignMessage.SetInvalidApiKeyErrorVariables.xml
Uploading policy AssignMessage.SetQuotaErrorVariables.xml
Uploading policy AssignMessage.SetQuotaInfo.xml
Uploading policy AssignMessage.SetRequestorIdErrorVariables.xml
Uploading policy AssignMessage.SetSpikeErrorVariables.xml
Uploading policy AssignMessage.SetXmlValidationErrorVariables.xml
Uploading policy ExtractVariables.GetAvailabilityRequestVariables.xml
Uploading policy ExtractVariables.GetAvailabilityResponseVariables.xml
Uploading policy ExtractVariables.GetCancellationRequestVariables.xml
Uploading policy ExtractVariables.GetCancellationResponseVariables.xml
Uploading policy ExtractVariables.GetRequestMessageType.xml
Uploading policy ExtractVariables.GetReservationRequestVariables.xml
Uploading policy ExtractVariables.GetReservationResponseVariables.xml
Uploading policy InvalidateCache.AvailabilityResponse.xml
Uploading policy JavaScript.AuthorizeIpAddress.xml
Uploading policy JavaScript.ConvertConfigurationToJson.xml
Uploading policy JavaScript.ExtractConfigurationVariables.xml
Uploading policy JavaScript.ExtractInvalidateCacheRequestVariables.xml
Uploading policy JavaScript.ModifyAvailabilityCacheResponse.xml
Uploading policy JavaScript.SendToLoggly.xml
Uploading policy KeyValueMap.GetApiConfiguration.xml
Uploading policy LookupCache.GetApiConfiguration.xml
Uploading policy MessageValidation.Xml.xml
Uploading policy PopulateCache.ApiConfiguration.xml
Uploading policy Quota.HourlyApp.xml
Uploading policy RaiseFault.GoToFaultRules.xml
Uploading policy RaiseFault.Xml.xml
Uploading policy ResetQuota.HourlyApp.xml
Uploading policy ResponseCache.AvailabilityResponse.xml
Uploading policy ServiceCallout.AuthenticateToApigee.xml
Uploading policy SpikeArrest.Global.xml
Uploading policy StatisticsCollector.SetCustomData.xml
Uploading policy VerifyApiKey.ValidateAppId.xml
Uploading target default
Deploying revision 205 of b2b-otaxml to intg
Going to POST to https://api.enterprise.apigee.com/v1/o/org-here/e/intg/apis/b2b-otaxml/revisions/205/deployments
Going go send command action=deploy&override=true&delay=60
Deployment on intg result: "{\n  \"code\" : \"distribution.NoProxiesToDeploy\",\n  \"message\" : \"No proxies available in apiproxy b2b-otaxml and revision 205. At least one proxy required to deploy\",\n  \"contexts\" : [ ]\n}"
Error: No proxies available in apiproxy b2b-otaxml and revision 205. At least one proxy required to deploy
Error: No proxies available in apiproxy b2b-otaxml and revision 205. At least one proxy required to deploy
at Request._callback (/home/rof/.nvm/v0.10.36/lib/node_modules/apigeetool/lib/commands/deployproxy.js:652:12)
at Request.self.callback (/home/rof/.nvm/v0.10.36/lib/node_modules/apigeetool/node_modules/request/request.js:198:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/home/rof/.nvm/v0.10.36/lib/node_modules/apigeetool/node_modules/request/request.js:1082:10)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/rof/.nvm/v0.10.36/lib/node_modules/apigeetool/node_modules/request/request.js:1009:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)
Warning: Command failed: Deployment on intg result: "{\n  \"code\" : \"distribution.NoProxiesToDeploy\",\n  \"message\" : \"No proxies available in apiproxy b2b-otaxml and revision 205. At least one proxy required to deploy\",\n  \"contexts\" : [ ]\n}"
Error: No proxies available in apiproxy b2b-otaxml and revision 205. At least one proxy required to deploy
Error: No proxies available in apiproxy b2b-otaxml and revision 205. At least one proxy required to deploy
at Request._callback (/home/rof/.nvm/v0.10.36/lib/node_modules/apigeetool/lib/commands/deployproxy.js:652:12)
at Request.self.callback (/home/rof/.nvm/v0.10.36/lib/node_modules/apigeetool/node_modules/request/request.js:198:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/home/rof/.nvm/v0.10.36/lib/node_modules/apigeetool/node_modules/request/request.js:1082:10)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/rof/.nvm/v0.10.36/lib/node_modules/apigeetool/node_modules/request/request.js:1009:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)
� Use --force to continue.

Have a look between these two lines - no proxy files:

Uploading target default
Deploying revision 205 of b2b-otaxml to intg

When I force our CI tool to revert to 0.5.4 of apigeetool, the whole build works fine (I haven't tried the versions in between):

Uploading target default
Uploading proxy admin
Uploading proxy default
Uploading proxy monitoring
Deploying revision 206 of b2b-otaxml to intg

Haven't had time to check the code myself yet.

deploynodeapp - remove requirement for main script in top-level directory

Please remove the requirement for the main script to reside in the top-level directory. This is unnecessary, and it forces me to adopt your directory structure for my app. For example, when i use -m .src/app.js, I get the following error:

Error: Main script file ./src/app.js must be in the top level directory

Here's how I worked around the problem:

  • Use -m app.js
  • Do a soft link as follows: ln -s .src/app.js app.js

Then everything works properly.

I consider this to be a defect. I don't want to use Apigee's directory structure, nor do I want it to influence my directory structure. Please remove the requirement that the main script must reside in the top-level directory structure. It will work just fine.

ApigeeTool is failing with non-cps orgs but passing in CPS orgs

Edge Cloud

I am able to recreate the issue

Error: KeyValueMap Operation CreateKeyValueMapEntry is not supported for the organization <org_name>

[CAN YOU REPRODUCE IN A TEST ORG?]
YES

[STEPS TO REPRODUCE]
Here is the snapshot. Where it passed are all CPS orgs and where it failed are non-CPS


phanim-macbookpro:~ phanim$ apigeetool addEntryToKVM -u -o <org_name_1> -e dev --mapName kvmap --entryName test1 --entryValue value1
Password: *********
Error: KeyValueMap Operation CreateKeyValueMapEntry is not supported for the organization <org_name>

phanim-macbookpro:~ phanim$ apigeetool addEntryToKVM -u -o <org_name_2> -e test --mapName testKVM --entryName phani_test_1 --entryValue value1
Password: *********
Error: KeyValueMap Operation CreateKeyValueMapEntry is not supported for the organization <org_name_2>

phanim-macbookpro:~ phanim$ apigeetool addEntryToKVM -u -o <org_name_3> -e test --mapName test --entryName phani_test_1 --entryValue value1
Password: *********
{"name":"phani_test_1","value":"value1"}

phanim-macbookpro:~ phanim$ apigeetool addEntryToKVM -u -o <org_name_4> -e test --mapName test --entryName phani_test_1 --entryValue value1
Password: *********
{"name":"phani_test_1","value":"value1"}

phanim-macbookpro:~ phanim$ apigeetool addEntryToKVM -u -o <org_name_5> -e stage --mapName test --entryName phani_test_1 --entryValue value1
Password: *********
Error: KeyValueMap Operation CreateKeyValueMapEntry is not supported for the organization <org_name_5>


[ADDITIONAL DETAILS, LINKS TO LOGS, DUMPS, SCREENSHOTS, ETC]

I think, the apigeeTool is using CPS based API

Just looked into Apigee Tool code
https://github.com/apigee/apigeetool-node/blob/master/lib/commands/addEntryToKVM.js

The request URL that is being formed is
uri = util.format('%s/v1/o/%s/e/%s/keyvaluemaps/%s/entries', opts.baseuri, opts.organization, opts.environment, opts.mapName);

It is a CPS request so fails in non-CPS

Do we fix code in ApigeeTool?

CPS API :
https://apidocs.apigee.com/management/apis/post/organizations/%7Borg_name%7D/keyvaluemaps/%7Bmap_name%7D/entries

Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE when working with on premise SSL endpoint

We have our own instance of Apigee and when trying to use our SSL endpoint (base URL) with apigeetool, I get:

Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
    at SecurePair.<anonymous> (tls.js:1380:32)
    at SecurePair.emit (events.js:92:17)
    at SecurePair.maybeInitFinished (tls.js:979:10)
    at CleartextStream.read [as _read] (tls.js:471:13)
    at CleartextStream.Readable.read (_stream_readable.js:340:10)
    at EncryptedStream.write [as _write] (tls.js:368:25)
    at doWrite (_stream_writable.js:225:10)
    at writeOrBuffer (_stream_writable.js:215:5)
    at EncryptedStream.Writable.write (_stream_writable.js:182:11)
    at write (_stream_readable.js:601:24)

There should be a way, how to specify the certificate used for validation of the endpoint certificate.

Any ideas how this can be done?

Thanks.

Error: Path /myproxy conflicts with existing deployment path for revision 13 of the APIProxy authorization in organization foo-organization

My CI tool just updated the npm package to 0.6.4 and now my deployments are broken because of the message

"Error: Path /myproxy conflicts with existing deployment path for revision 13 of the APIProxy authorization in foo-organization".

When I reverted back to 0.6.3 the deploy worked again, so there is something wrong with the version matching. It could well be that it is broken because of issue #54 . This was also broken for me, so I switched to the --api flag instead of -n.

The command that I ran:
apigeetool deployproxy -u ${bamboo_APIGEE_USERNAME} -p ${bamboo_APIGEE_PASSWORD} -o ${bamboo_APIGEE_ORGANIZATION} -e ${bamboo_APIGEE_ENVIRONMENT} --api $apiname -d .

apigeetool deployproxy creates duplicate revisions

Using apigeetool 0.6.4 on windows 10 with node v4.6.1 yields interesting results when deployproxy is called:

multi-revision

I can reproduce this reliably and the new API version, while deployed, does not work until it is undeployed (which undeploys both versions) and redeployed.

The last messages from the deployproxy output are:

Final result: err = null for deployments = [
{
  "name":"yep*dev",
  "environment":"dev",
  "revision":8,
  "state":"deployed",
  "basePath":"/yep*-dev/v1",
  "uris":[
    "http://*dev.apigee.net/yep*-dev/v1/yep*-dev/v1",
    "https://*dev.apigee.net/yep*-dev/v1/yep*-dev/v1"
  ]
}]
"yep*-dev" Revision 8
  deployed
  environment = dev
  base path = /yep*-dev/v1
  URI = http://*-dev.apigee.net/yep*-dev/v1/yep*-dev/v1
  URI = https://*-dev.apigee.net/yep*-dev/v1/yep*-dev/v1

Please note that the API returns basePath twice in the URIs.

basepath specified in both proxy code and CLI causes deployment issues

(Originally reported by @antxxxx here: #25.)

When basepath is set in the proxy code - ie. if ProxyEndpoint/HTTPProxyConnection/BasePath is set and you pass basepath into apigeetool, you end up with a messed up deployment. When using this to deploy an already existing proxy, it created the new revision correctly, but when it did the deploy, it did not undeploy the old revision, so we ended up with two revisions deployed to the same environment.

To recreate this - create a new proxy with 2 revisions - both must have basepath set in the proxy
If you use the management api (which is what Apigeetool uses to deploy) ie - POST to https://api.enterprise.apigee.com/v1/organizations/{org_name}/environments/{env_name}/apis/{api_name}/revisions/{revision_number}/deployments
with body
action=deploy&override=true&delay=60&basepath=/v1/weather
Then you end up with both revisions showing as deployed.
If basepath is not set in the proxy, then passing basepath in the management api does work - although then the base bath does not show up on the web interface
If basepath is set in the proxy, then not passing basepath in the management api does work

No access to 'context' variable

Hi, Im using A127 as my node.js template for Apigee Node app and im deploying it using apigeetool-node (deploynodeapp command).

Deployment is good but API is having an error("context is not defined") when I tried to use the 'context' variable. Im using it for getting a local variable from the KVM.
I've notice that apigeetool node is deploying under 'node' folder unlike when creating a javascript file, it is under jsc. When I try to create a JS script under jsc folder(using the UI) it has access to the 'context' variable.
Why is that so?

apigeetool when deploying a proxy doesn't support setting the virtualhosts as in deploying a nodeapp

We have our own instance of Apigee and when trying to deploy a node app we do the following:

apigeetool deploynodeapp -u [email protected] -o sdoe -e test -n 'Test Node App 2' -d . -m app.js -b /node2 -v 'default,secure'

But this same option is not available when deploying a proxy:

apigeetool deployproxy  -u [email protected] -o sdoe  -e test -n example-proxy -d .

you can't do this:

apigeetool deployproxy  -u [email protected] -o sdoe  -e test -n example-proxy -d . -v 'default,secure'

Any ideas how to overcome this without defining it into the XML code?
Thanks.

Deployment fails when a keystore or target server is added in the service callout policy

Deployment through the node tool fails during the validation of the policy schema when a keystore or target server is added to the service callout policy. When I create a zip of the same proxy bundle and upload it to management UI then it deploys fine.

Please find my keystore configuration in Service callout policy:

<HTTPTargetConnection>
  <URL>https://myURL.com</URL>
  <SSLInfo>
      <Enabled>true</Enabled>
      <ClientAuthEnabled>true</ClientAuthEnabled>
      <KeyStore>openiam_tls_keystore</KeyStore>
      <KeyAlias>openiam_tls_client_cert</KeyAlias>
  </SSLInfo>
</HTTPTargetConnection>

I tried to debug the issue and following is my understanding-

Apigee nodetool makes a post call to https://api.enterprise.apigee.com/v1/o//apis//revisions//policies with policy content in body and in response Apigee is throwing back the error:

"{\n  \"code\" : \"beans.OtherValidationError\",\n  \"message\" : \"Unexpected Validation Error null\",\n  \"contexts\" : [ ]\n}"

node proxy deployment create duplicate NPM modules

While deploying proxies having nodejs resource in opts['upload-modules'] = true; mode. Apigeetool creates multiple zips of different node_modules. eg node_modules_yaml.zip, node_modules_mustache.zip along with these it also creates node_modules.zip

node_modules.zip obviously has all the modules within hence we don't need node_modules_yaml.zip, node_modules_mustache.zip zips or need not create node_modules.zip and retain other zips.

The -n option does not work.

The -n option should be for specifying the "name" of the proxy. This option doesn't work anymore -- when I use "-n" in the command line, it is not recognized. Use of --api does work however. But, apigeetool isn't backward compatible for scripts that used "-n".

Also -- apigeetool -h shows two "-n" options (one for --api and one for --netrc). This should be cleaned up.

Please ignore devDependencies in deploynodeapp

I can't deploy on Apigee with my package.json "as is" with the -R option because the devDependencies that I use (e.g., gulp, etc.) are too large and exceeds the Proxy Bundle limit. As a workaround, I have to do the following:

  • Do npm install --production
  • Use the -U option

But this is still a defect. Please fix your deployment tool to use npm install --production. That way, you're just pulling in the dependencies from package.json, and everything works as expected.

--api alias -n broken

Throws Invalid arguments: Error: Unknown argument

Most likely caused by @DinoChiesa #37 as it's using the same alias

This caused our deployments to fail. We've had to work around this by using --api instead of -n.

Documentation is still showing -n as an alias of --api for deploynodeapp.

Can you please bump to a major version v1? This was a breaking change, but the version bump was done as a patch

cc @theganyo @mukundha

MFA Support

Is there any plan to add MFA support for apigeetool?

Change virtualhost handling to default AND secure (by default)

Today when I create and deploy a proxy to Apigee through the UI, it uses both default and secure virtualhosts. Why is the behavior for apigeetool different? I would expect it to always use default and secure, though I could override that with a command line param if I wished.

zip files and managing revisions

When deploying nodejs applications using apigeetool, all the folders are compressed (zipped) before they are deployed to Edge (the main script is not compressed). Generally speaking, I think it is a great idea when it comes to folders like node_modules. But the command compresses other folders also. for ex: when deploying an a127 project, it compresses the "controllers" folder. When this happens, I lose the ability to make the smallest of edits in Edge. Every edit made outside of Edge will result in a new revision. I wonder if it makes sense to have a file similar to a .npmignore that tells you what files/folders to not zip or perhaps only compress node_modules by default and leave everything else.

Broken in v0.10 and v0.12

/Users/adammagaluk/Software/Edge/apigeetool-node/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js:5
const Hoek = require('hoek');
^^^^^
SyntaxError: Use of const in strict mode.
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/adammagaluk/Software/Edge/apigeetool-node/node_modules/request/node_modules/hawk/lib/index.js:5:33)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

Error: unexpected end of file

apigeetool deploynodeapp -o -e test -n -m index.js -b -v https_vhost -P

If I remove the parameter -P, the apiproxy uploads correctly, but I need to preserver-policies
Any help?

running remotetests takes a looong time

The deploy proxy in remotetests steps takes about 50-60 seconds and sometimes timing out

Proposal
1 - use a simpler proxy with just express - there is no need to include node_modules if its just express, so the bundle size could become significantly smaller and deployment faster
2 - for non-nodejs test, we could use a simpler proxy that does not have nodejs resources - might fasten the tests

deployproxy fails with a 500 error on large-ish proxy

I have a proxy which includes JWT creation (from https://github.com/apigee/iloveapis2015-jwt-jwe-jws) and thus includes some JARs, for a total of 2.7mb. When deploying this, it always fails with:

c:>apigeetool deployproxy -p password -u [email protected] -o organisation-name -n proxy-name -k -V -a 50 -i
...
Uploading java resource apigee-edge-callout-jwt-signed-1.0.6.jar
Uploading java resource json-smart-1.3.jar
Uploading java resource nimbus-jose-jwt-3.10.jar
Uploading java resource Utils-Callout.jar
...
Uploading policy VerifyAPIKey.xml
Error: Error uploading policy: 500
Error: Error uploading policy: 500
at Request._callback (C:..path..npm\node_modules\apigeetool\lib\commands\deployproxy.js:397:18)
at Request.self.callback (C:..path..npm\node_modules\apigeetool\node_modules\request\request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request. (C:..path..npm\node_modules\apigeetool\node_modules\request\request.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage. (C:..path..npm\node_modules\apigeetool\node_modules\request\request.js:1091:12)
at IncomingMessage.g (events.js:292:16)
at emitNone (events.js:91:20)

Uploading smaller proxies does work well.

Uploading a zip of the proxy via the Apigee UI works well (1-2 minutes).

Having looked at the Node source code, and tried uploading to a new proxy name, I'm expecting the uploader to make a zip file:

var zipBuf = ziputils.makeOneFileZip(ProxyBase, rootEntryName, rootDoc);

and upload that; however, it seems to upload the resources, policies, proxies and targets one by one.

Has anyone seen this behavior ?

Freddie Vander Elst

New proxies created in Apigeetool are not automatically added to custom roles for edit

Background:
Create 2 users (user 1 and user 2) in custom role. The custom role has CREATE and VIEW abilities on all API proxies.

+Scenario 1 (this works as expected):+

  1. With user 1, create a new proxy in UI.
  2. Note that the new proxy is automatically added to the custom role in which the user belongs. The permissions include View, Edit and Delete, as well as Deploy on the new proxy.
  3. Now user 2 logs into UI and can edit the newly created proxy that was created by user 1.

+Scenario 2 (this fails)+

  1. With user 1, create a new proxy using Apigee tool (https://github.com/apigee/apigeetool-node#deployproxy)
  2. Note that you get a 403 forbidden back, but the proxy is still created. This is not the point of failure for this JIRA ticket (filed separately in APIRT-2122).
  3. Now user 2 logs into UI and CANNOT edit the newly created proxy that was created by user 1. The problem is that the new proxy is not automatically added to the custom role with the correct permissions (The permissions include View, Edit and Delete, as well as Deploy on the new proxy).

I think it is a bad user experience if the UI takes care of creating this entry in the custom role(prob via an additional MS API call), but Apigeetool does not. IMO these 2 tools should be at parity for this feature since both are officially supported by Apigee.

Add configuration to set commonly used values

It would be great if I could set my apigeetool config properties, like username and org so that I didn't have to supply them with every request. These might be configured using something like apigeetool config user [email protected] and would include a config listing.

API errors not reported?

@theganyo or who else this concerns

It looks like the -V or --debug -D flags don't return errors from the API itself. Here's what I'm getting back:

Please report a bug if this causes problems.
Error: Error: Error uploading policy: 400
Error: Error uploading policy: 400
    at Request._callback (/usr/local/lib/node_modules/apigeetool/lib/commands/deployproxy.js:376:18)
    at Request.self.callback (/usr/local/lib/node_modules/apigeetool/node_modules/request/request.js:123:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/usr/local/lib/node_modules/apigeetool/node_modules/request/request.js:1047:14)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/apigeetool/node_modules/request/request.js:998:12)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)

Is there an option I'm missing here? At first glance, the error messages don't seem to be printed out the console:

}, function(err, req, body) {
if (err) {
itemDone(err);
} else if ((req.statusCode === 200) || (req.statusCode === 201)) {
itemDone();
} else {
itemDone(new Error(util.format('Error uploading policy: %s',
req.statusCode)));
}

Though I haven't done a deep-dive into the code yet. Let me know how I can help. Thanks!

Using deploynodeapp with -i throws error but successfully uploads the API.

$ apigeetool ... deploynodeapp -V -d . -e test -n mongo-nodejs1 -o merck -m api-mongo.js -b /v1/mongodb -i

API mongo-nodejs1 does not exist. Going to create revision 1
Creating revision 1 of API mongo-nodejs1
Uploading resource README.txt
Uploading resource api-mongo.js
Uploading resource node_modules.zip
Uploading resource package.json
Creating the target endpoint
Creating the proxy endpoint
Not deploying the proxy right now

TypeError: Cannot read property 'aPIProxy' of undefined
at Object.module.exports.parseDeploymentResult (/usr/local/lib/node_modules/apigeetool/lib/commands/parsedeployments.js:42:9)
at /usr/local/lib/node_modules/apigeetool/lib/commands/deploynodeapp.js:120:43
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:254:17
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:157:25
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:251:21
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:615:34
at deployProxy (/usr/local/lib/node_modules/apigeetool/lib/commands/deploynodeapp.js:449:5)
at async.series.deployResult (/usr/local/lib/node_modules/apigeetool/lib/commands/deploynodeapp.js:108:7)
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:610:21
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:249:17

Deploy particular revison

Is there a way to use apigeetool to deploy a particular revision of the app to an environment? I know how to use deploynodeapp to deploy to an environment, but I would like to propagate an existing revision of the app from test to prod. Is that possible using apigeetool?

Update to 'request' library breaks Apigeetool Node 0.10 compatibility

The recent update to Request (2.82.0) specifies "hawk": "~6.0.2" in its dependencies.

Request has marked 2.82.0 as compatible with "request": "^2.63.0" as specified by this project's package.json

The recent updates to Hawk will not work with Node < 4. The update makes Apigeetool incompatible with Node 0.10.32

Favor package.json over -m for start script

package.json allows for defining the default start command (reference).

…
    "scripts": {
    "start": "node app.js"
    }
…

Keep the -m for the CLI to declare (or override) the main script to start, but if the declaration is in the package.json, Edge (or apigeetool) should use it.

Format of .netrc file is not documented

The new feature to read credentials from a .netrc file is potentially useful; however, the format of the .netrc file is not documented in the read me. What do the contents of this file look like, and is it placed in the home directory? Would a copy in the cwd override a home directory copy?

Existing copy of a to be created zip file results in a 409 error

When running deployproxy on a proxy, it creates zipped copies of sub directories in the resources/node directory and uploads them. If there is already a file with that name in the directory (say you are editing an export), then it will upload both of them and error with a 409.

This should either be caught earlier, or the zip should be favored or ignored. At the very least, a specific error should be thrown.

Use configuration file instead of so many variables

Hi,

I would like to ask for a feature request.
Since it is too tedious to type everything in a single command like -o org -e environment
Also it is hard to maintain.
Can there be a file like '.apigee' where apigeetool node reads file for the options?
You may refer to AWS-cli, it can have many profiles with different environment setup.

fetchproxy requires revision while docs says revision param is optional

As per the docs - the -r argument is optional for fetchproxy but when we try to run the command without the argument, it fails with the following error

$ apigeetool fetchproxy -u [email protected] -o saisarantest -n currency-v1

Error: org, api and revision must all be specified! {"username":"[email protected]","organization":"saisarantest","api":"currency-v1","interactive":true,"baseuri":"https://api.enterprise.apigee.com","asynclimit":4,"password":{}}

Per project configs

I wanted to query whether it would be possible to setup config files within our projects to specify common options such as base path etc which we could store in git.

This would make deployments much easier, and by requiring each person to have their username and password as a environment variable, it'd mitigate any leaking of sensitive data into git.

Obviously I could create a wrapper tool which performs this task and then simply builds up the command to execute, but it would be nicer for this functionality to be built into the tool itself.

Perhaps some sort of . rc file which can be automatically read if it exists, which sets default values such as baseuri etc, but can still be overridden directly in the command via the current flags.

I'm happy to open a PR implementing this, but file name and format need discussing first.

Re-deploying a Node.js proxy

We would like to use the agile approach of developing APIs. This means, we start small, with several features and then we constantly improve the API by adding more and more features.

In case of a Node.js base proxy, this means developing the API locally and repeatedly deploying it to Apigee. We use the deploynodeapp command of apigeetool. It is intended to be used for initial deployment. And this is actually our problem. If I deploy the Node.js app and add some Apigee policies to the proxy, next time I re-deploy the Node.js app, the policies get overwritten.

We need a way, how to repeatedly deploy a Node.js app without having to re-create all the policies we need. Or what is the proper way, how to do this?

I suppose I can use the deployproxy command, but first I need to zip all Node.js folders the way Apigee can consume them. Maybe there could be a parameter to the deployproxy command, which will make sure, that the ZIP files are created before the proxy is deployed.

Error: unable to verify the first certificate

This isn't a defect in apigeetool, but I'm unable to use it behind my corporate firewall.
As long as I'm outside the firewall, apigeetool works properly.

I've tried the following, and no joy:

  • npm config set registry="http://registry.npmjs.org/"
  • npm config set strict-ssl false

Do you have any ideas for helping node get through/past the firewall?

Thanks.

When running deployproxy with -i (just upload a new revision, don't deploy it), it works, but throws an error

When running deployproxy with -i (just upload a new revision, don't deploy it), it works, but throws an error (shown below). It seems to be still attempting to parse the deployment message, even though there isn't one.
+++++++++++++++++++++++++++++

Not deploying the proxy right now

TypeError: Cannot read property 'aPIProxy' of undefined
at Object.module.exports.parseDeploymentResult (/usr/local/lib/node_modules/apigeetool/lib/commands/parsedeployments.js:42:9)
at /usr/local/lib/node_modules/apigeetool/lib/commands/deployproxy.js:116:43
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:254:17
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:157:25
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:251:21
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:615:34
at deployProxy (/usr/local/lib/node_modules/apigeetool/lib/commands/deployproxy.js:576:5)
at async.series.deployResult (/usr/local/lib/node_modules/apigeetool/lib/commands/deployproxy.js:104:7)
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:610:21
at /usr/local/lib/node_modules/apigeetool/node_modules/async/lib/async.js:249:17

Use same pattern for vhosts with environments

While you can specify multiple virtualhosts at once, like -v secure,default but you cannot specify multiple environments in this way. It would be handy to have the same pattern, so one could use -e test,prod to deploy to both proxies at once.

fetchproxy doesn't return control back to callback if success

request.get( { uri: uri, encoding: 'binary' }, function (err,res,body) {
    if (err) {
      cb(err);
    } else {
      if (opts.debug) {
        console.log ( 'Received: ' + res.statusCode + ' the following headers: ' + JSON.stringify(res.headers) );
      }
      if (res.statusCode !== 200) {
        cb(new Error(util.format('Received error %d when fetching proxy: %s',
                    res.statusCode, body)));
      } else {
        fs.writeFile(f, body, 'binary', function(err) {
            if (err) {
                console.log( "Failed to write file: " + f );
                console.log( "Error text: " + err );
            }
            else {
                console.log( 'Save file: ' + f );
            }
        });
      }
    }
  });

Ideally above code should call cb on success...

return cb(err);
//or
return cb(null);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.