From b2f9d38bf9c41d44324eaeda43ba8083a1c9b517 Mon Sep 17 00:00:00 2001 From: Gian Franco Zabarino Date: Thu, 19 Jul 2018 04:33:18 -0300 Subject: [PATCH 1/6] Extracted all APIs to configuration variables. --- README.md | 5 +++++ config/default.js | 7 +++++++ src/handlers/util.js | 6 +++--- src/test/app.test.js | 22 +++++++++++----------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 22a63e1..915f2e9 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,11 @@ To override default settings please add them to a file `./config/local.js`: - `RABBITMQ.NOTIFICATIONS_EXCHANGE_NAME`: the notification RabbitMQ's topic exchange name - `LOGENTRIES_TOKEN`: the Logentries token generated from https://logentries.com/ - `API_BASE_URL`: the base url to the API server to get project/user info +- `API_URL_PROJECTS`: `API_BASE_URL` path accessed by this project +- `API_URL_MEMBERS`: `API_BASE_URL` path accessed by this project +- `API_URL_USERS`: `API_BASE_URL` path accessed by this project +- `API_URL_AUTHORIZATIONS`: `API_BASE_URL` path accessed by this project +- `API_URL_TOPICS`: `API_BASE_URL` path accessed by this project - `DISABLE_DELAY_EXCHANGE`: Disable exchage type delay and use 'direct' instead(Note: after changing this delete existing delay exchange ) - `TC_SLACK_WEBHOOK_URL`: slack webhook url - `SLACK_ICON_URL`: slack webhook icon url diff --git a/config/default.js b/config/default.js index 62b9fd8..fcf18d9 100644 --- a/config/default.js +++ b/config/default.js @@ -34,6 +34,13 @@ module.exports = { // The base url to the project/user API server API_BASE_URL: 'http://localhost:3001', + // The different paths of API_BASE_URL accessed by this project + API_URL_PROJECTS: '/v4/projects', + API_URL_MEMBERS: '/v3/members', + API_URL_USERS: '/v3/users', + API_URL_AUTHORIZATIONS: '/v3/authorizations', + API_URL_TOPICS: '/v5/topics', + // Disable delay exchange and use direct instead ( delete existing delay exchnge after changing) DISABLE_DELAY_EXCHANGE: false, diff --git a/src/handlers/util.js b/src/handlers/util.js index 9a264b6..6c701cf 100644 --- a/src/handlers/util.js +++ b/src/handlers/util.js @@ -60,7 +60,7 @@ const createProjectDiscourseNotification = Promise.coroutine( return Promise.reject(new Error('Error retrieving system token')); } const options = { - url: `${config.get('API_BASE_URL')}/v5/topics/create`, + url: `${config.get('API_BASE_URL')}${config.get('API_URL_TOPICS')}/create`, method: 'POST', headers: { Authorization: `Bearer ${token}`, @@ -138,7 +138,7 @@ function* getProjectById(id) { return Promise.reject(new Error('Error retrieving system token')); } return yield requestPromise({ - url: `${config.get('API_BASE_URL')}/v4/projects/${id}`, + url: `${config.get('API_BASE_URL')}${config.get('API_URL_PROJECTS')}/${id}`, headers: { Authorization: `Bearer ${token}`, }, @@ -159,7 +159,7 @@ function* getUserById(id) { // eslint-disable-line require-yield } return reject(new Error('user not found')); }; - return requestPromise({ url: `${config.get('API_BASE_URL')}/v3/members/_search/?query=userId:${id}` }, cb); + return requestPromise({ url: `${config.get('API_BASE_URL')}${config.get('API_URL_MEMBERS')}/_search/?query=userId:${id}` }, cb); } diff --git a/src/test/app.test.js b/src/test/app.test.js index adc26ed..ab10017 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -172,33 +172,33 @@ describe('app', () => { // Stub the calls to API server stub = sinon.stub(request, 'get'); const stubArgs = { - url: `${config.API_BASE_URL}/v4/projects/1`, + url: `${config.API_BASE_URL}${config.API_URL_PROJECTS}/1`, }; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleProjects.project1); - stubArgs.url = `${config.API_BASE_URL}/v4/projects/1000`; + stubArgs.url = `${config.API_BASE_URL}${config.API_URL_PROJECTS}/1000`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 404 }); - stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:1`; + stubArgs.url = `${config.API_BASE_URL}${config.API_URL_MEMBERS}/_search/?query=userId:1`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleUsers.user1); - stubArgs.url = `${config.API_BASE_URL}/v3/users/1000`; + stubArgs.url = `${config.API_BASE_URL}${config.API_URL_USERS}/1000`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 404 }); - stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:40051331`; + stubArgs.url = `${config.API_BASE_URL}${config.API_URL_MEMBERS}/_search/?query=userId:40051331`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleUsers.user1); - stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:50051333`; + stubArgs.url = `${config.API_BASE_URL}${config.API_URL_MEMBERS}/_search/?query=userId:50051333`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleUsers.user1); postStub = sinon.stub(request, 'post'); - postStub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v3/authorizations/`)) + postStub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}${config.API_URL_AUTHORIZATIONS}/`)) .yields(null, { statusCode: 200 }, sampleAuth); postStub.withArgs(sinon.match.has('url', config.TC_SLACK_WEBHOOK_URL)) @@ -256,7 +256,7 @@ describe('app', () => { const callbackCount = 1; request.get.restore(); stub = sinon.stub(request, 'get'); - stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v3/members/_search/?query=userId:8547900`)) + stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}${config.API_URL_MEMBERS}/_search/?query=userId:8547900`)) .yields(null, { statusCode: 200 }, sampleUsers.user1); sendTestEvent(sampleEvents.updatedInReview, 'project.updated'); @@ -285,7 +285,7 @@ describe('app', () => { it('should create `Project.Reviewed` and `Project.AvailableToClaim` and copilot slack notifications and repost after delay till TTL', (done) => { request.get.restore(); stub = sinon.stub(request, 'get'); - stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v4/projects/1`)) + stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}${config.API_URL_PROJECTS}/1`)) .yields(null, { statusCode: 200 }, sampleProjects.projectTest); let assertCount = 0; @@ -372,9 +372,9 @@ describe('app', () => { it('should create `Project.Member.CopilotJoined` notification and slack copilot joined notification', (done) => { request.get.restore(); stub = sinon.stub(request, 'get'); - stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v4/projects/1`)) + stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}${config.API_URL_PROJECTS}/1`)) .yields(null, { statusCode: 200 }, sampleProjects.projectTest); - stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v3/members/_search/?query=userId:40051331`)) + stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}${config.API_URL_MEMBERS}/_search/?query=userId:40051331`)) .yields(null, { statusCode: 200 }, sampleUsers.user1); sendTestEvent(sampleEvents.memberAddedCopilot, 'project.member.added'); From 3302c593f3d8686ee1785fbf3371212016ac6848 Mon Sep 17 00:00:00 2001 From: Gian Franco Zabarino Date: Thu, 19 Jul 2018 23:38:45 -0300 Subject: [PATCH 2/6] Changed configuration variables approach by including the base url in each service's url. --- README.md | 11 +++++------ config/default.js | 15 ++++++--------- config/development.json | 6 +++++- config/production.json | 6 +++++- config/test.js | 6 +++++- src/handlers/util.js | 6 +++--- src/test/app.test.js | 22 +++++++++++----------- 7 files changed, 40 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 915f2e9..2031032 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,11 @@ To override default settings please add them to a file `./config/local.js`: - `RABBITMQ.DELAY_DURATION`: Amount of delay before reposting unclaimed project - `RABBITMQ.NOTIFICATIONS_EXCHANGE_NAME`: the notification RabbitMQ's topic exchange name - `LOGENTRIES_TOKEN`: the Logentries token generated from https://logentries.com/ -- `API_BASE_URL`: the base url to the API server to get project/user info -- `API_URL_PROJECTS`: `API_BASE_URL` path accessed by this project -- `API_URL_MEMBERS`: `API_BASE_URL` path accessed by this project -- `API_URL_USERS`: `API_BASE_URL` path accessed by this project -- `API_URL_AUTHORIZATIONS`: `API_BASE_URL` path accessed by this project -- `API_URL_TOPICS`: `API_BASE_URL` path accessed by this project +- `API_URL_PROJECTS`: the projects service url +- `API_URL_MEMBERS`: `API_BASE_URL` the members service url +- `API_URL_USERS`: `API_BASE_URL` the users service url +- `API_URL_AUTHORIZATIONS`: `API_BASE_URL` the authorizations service url +- `API_URL_TOPICS`: `API_BASE_URL` the topics service url - `DISABLE_DELAY_EXCHANGE`: Disable exchage type delay and use 'direct' instead(Note: after changing this delete existing delay exchange ) - `TC_SLACK_WEBHOOK_URL`: slack webhook url - `SLACK_ICON_URL`: slack webhook icon url diff --git a/config/default.js b/config/default.js index fcf18d9..4ae5e31 100644 --- a/config/default.js +++ b/config/default.js @@ -31,15 +31,12 @@ module.exports = { // Token is generated from https://logentries.com/ LOGENTRIES_TOKEN: '', - // The base url to the project/user API server - API_BASE_URL: 'http://localhost:3001', - - // The different paths of API_BASE_URL accessed by this project - API_URL_PROJECTS: '/v4/projects', - API_URL_MEMBERS: '/v3/members', - API_URL_USERS: '/v3/users', - API_URL_AUTHORIZATIONS: '/v3/authorizations', - API_URL_TOPICS: '/v5/topics', + // The different services used by this project + API_URL_PROJECTS: 'http://localhost:3001/v4/projects', + API_URL_MEMBERS: 'http://localhost:3001/v3/members', + API_URL_USERS: 'http://localhost:3001/v3/users', + API_URL_AUTHORIZATIONS: 'http://localhost:3001/v3/authorizations', + API_URL_TOPICS: 'http://localhost:3001/v5/topics', // Disable delay exchange and use direct instead ( delete existing delay exchnge after changing) DISABLE_DELAY_EXCHANGE: false, diff --git a/config/development.json b/config/development.json index 6bbf704..cf2162c 100644 --- a/config/development.json +++ b/config/development.json @@ -8,5 +8,9 @@ "DELAYED_NOTIFICATIONS_EXCHANGE_NAME": "dev.connect-notifications-reminders" }, - "API_BASE_URL": "http://api.topcoder-dev.com" + "API_URL_PROJECTS": "http://api.topcoder-dev.com/v4/projects", + "API_URL_MEMBERS": "http://api.topcoder-dev.com/v3/members", + "API_URL_USERS": "http://api.topcoder-dev.com/v3/users", + "API_URL_AUTHORIZATIONS": "http://api.topcoder-dev.com/v3/authorizations", + "API_URL_TOPICS": "http://api.topcoder-dev.com/v5/topics" } diff --git a/config/production.json b/config/production.json index 38a2784..0b861e1 100644 --- a/config/production.json +++ b/config/production.json @@ -11,5 +11,9 @@ "SLACK_CHANNEL_COPILOTS": "#connect-copilots", "SLACK_CHANNEL_NPS": "#customer-experience", - "API_BASE_URL": "http://api.topcoder.com" + "API_URL_PROJECTS": "http://api.topcoder.com/v4/projects", + "API_URL_MEMBERS": "http://api.topcoder.com/v3/members", + "API_URL_USERS": "http://api.topcoder.com/v3/users", + "API_URL_AUTHORIZATIONS": "http://api.topcoder.com/v3/authorizations", + "API_URL_TOPICS": "http://api.topcoder.com/v5/topics" } diff --git a/config/test.js b/config/test.js index 6fb73e3..b23cb28 100644 --- a/config/test.js +++ b/config/test.js @@ -22,7 +22,11 @@ module.exports = { DELAY_DURATION: 0, }, TC_SLACK_WEBHOOK_URL: 'http://localhost:3001/slack', - API_BASE_URL: 'http://localhost:3001', + API_URL_PROJECTS: 'http://localhost:3001/v4/projects', + API_URL_MEMBERS: 'http://localhost:3001/v3/members', + API_URL_USERS: 'http://localhost:3001/v3/users', + API_URL_AUTHORIZATIONS: 'http://localhost:3001/v3/authorizations', + API_URL_TOPICS: 'http://localhost:3001/v5/topics', AUTH0_URL: process.env.DEV_AUTH0_URL || '', AUTH0_AUDIENCE: process.env.DEV_AUTH0_AUDIENCE || '', TOKEN_CACHE_TIME: process.env.DEV_TOKEN_CACHE_TIME || 86400000, diff --git a/src/handlers/util.js b/src/handlers/util.js index 6c701cf..8242738 100644 --- a/src/handlers/util.js +++ b/src/handlers/util.js @@ -60,7 +60,7 @@ const createProjectDiscourseNotification = Promise.coroutine( return Promise.reject(new Error('Error retrieving system token')); } const options = { - url: `${config.get('API_BASE_URL')}${config.get('API_URL_TOPICS')}/create`, + url: `${config.get('API_URL_TOPICS')}/create`, method: 'POST', headers: { Authorization: `Bearer ${token}`, @@ -138,7 +138,7 @@ function* getProjectById(id) { return Promise.reject(new Error('Error retrieving system token')); } return yield requestPromise({ - url: `${config.get('API_BASE_URL')}${config.get('API_URL_PROJECTS')}/${id}`, + url: `${config.get('API_URL_PROJECTS')}/${id}`, headers: { Authorization: `Bearer ${token}`, }, @@ -159,7 +159,7 @@ function* getUserById(id) { // eslint-disable-line require-yield } return reject(new Error('user not found')); }; - return requestPromise({ url: `${config.get('API_BASE_URL')}${config.get('API_URL_MEMBERS')}/_search/?query=userId:${id}` }, cb); + return requestPromise({ url: `${config.get('API_URL_MEMBERS')}/_search/?query=userId:${id}` }, cb); } diff --git a/src/test/app.test.js b/src/test/app.test.js index ab10017..b892abf 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -172,33 +172,33 @@ describe('app', () => { // Stub the calls to API server stub = sinon.stub(request, 'get'); const stubArgs = { - url: `${config.API_BASE_URL}${config.API_URL_PROJECTS}/1`, + url: `${config.API_URL_PROJECTS}/1`, }; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleProjects.project1); - stubArgs.url = `${config.API_BASE_URL}${config.API_URL_PROJECTS}/1000`; + stubArgs.url = `${config.API_URL_PROJECTS}/1000`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 404 }); - stubArgs.url = `${config.API_BASE_URL}${config.API_URL_MEMBERS}/_search/?query=userId:1`; + stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:1`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleUsers.user1); - stubArgs.url = `${config.API_BASE_URL}${config.API_URL_USERS}/1000`; + stubArgs.url = `${config.API_URL_USERS}/1000`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 404 }); - stubArgs.url = `${config.API_BASE_URL}${config.API_URL_MEMBERS}/_search/?query=userId:40051331`; + stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:40051331`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleUsers.user1); - stubArgs.url = `${config.API_BASE_URL}${config.API_URL_MEMBERS}/_search/?query=userId:50051333`; + stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:50051333`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleUsers.user1); postStub = sinon.stub(request, 'post'); - postStub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}${config.API_URL_AUTHORIZATIONS}/`)) + postStub.withArgs(sinon.match.has('url', `${config.API_URL_AUTHORIZATIONS}/`)) .yields(null, { statusCode: 200 }, sampleAuth); postStub.withArgs(sinon.match.has('url', config.TC_SLACK_WEBHOOK_URL)) @@ -256,7 +256,7 @@ describe('app', () => { const callbackCount = 1; request.get.restore(); stub = sinon.stub(request, 'get'); - stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}${config.API_URL_MEMBERS}/_search/?query=userId:8547900`)) + stub.withArgs(sinon.match.has('url', `${config.API_URL_MEMBERS}/_search/?query=userId:8547900`)) .yields(null, { statusCode: 200 }, sampleUsers.user1); sendTestEvent(sampleEvents.updatedInReview, 'project.updated'); @@ -285,7 +285,7 @@ describe('app', () => { it('should create `Project.Reviewed` and `Project.AvailableToClaim` and copilot slack notifications and repost after delay till TTL', (done) => { request.get.restore(); stub = sinon.stub(request, 'get'); - stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}${config.API_URL_PROJECTS}/1`)) + stub.withArgs(sinon.match.has('url', `${config.API_URL_PROJECTS}/1`)) .yields(null, { statusCode: 200 }, sampleProjects.projectTest); let assertCount = 0; @@ -372,9 +372,9 @@ describe('app', () => { it('should create `Project.Member.CopilotJoined` notification and slack copilot joined notification', (done) => { request.get.restore(); stub = sinon.stub(request, 'get'); - stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}${config.API_URL_PROJECTS}/1`)) + stub.withArgs(sinon.match.has('url', `${config.API_URL_PROJECTS}/1`)) .yields(null, { statusCode: 200 }, sampleProjects.projectTest); - stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}${config.API_URL_MEMBERS}/_search/?query=userId:40051331`)) + stub.withArgs(sinon.match.has('url', `${config.API_URL_MEMBERS}/_search/?query=userId:40051331`)) .yields(null, { statusCode: 200 }, sampleUsers.user1); sendTestEvent(sampleEvents.memberAddedCopilot, 'project.member.added'); From 19f9bc2931c8c6110f815e611d2cee35e697fd35 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Thu, 24 Jan 2019 13:17:26 +0530 Subject: [PATCH 3/6] =?UTF-8?q?Github=20issue#98,=20Copy=20changes=20for?= =?UTF-8?q?=20new=20project=20creation=20CodeBot=20message=20=E2=80=94=20U?= =?UTF-8?q?pdated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/constants.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/constants.js b/src/common/constants.js index ee9bdee..07581fd 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -165,8 +165,8 @@ module.exports = { discourse: { project: { created: { - title: 'Your project has been created, and we\'re ready for your specification', - content: data => `Hello, Coder here! Your project '${data.projectName}' has been drafted. If you have your requirements documented, just verify it against our checklist and then upload it on the Scope section. Once you've finalized your scope, select the "Submit for Review" button. Topcoder will then review your drafted project and will assign a manager to get your delivery in-progress! Get stuck or need help? Email us at support@topcoder.com.`, + title: 'Share requirements and submit your draft project for review.', + content: data => `Your project '${data.projectName}' has been drafted. If you have requirements documented, share them for review under the Files or Links section. Once you’re ready, click the "Submit for Review" button. Topcoder will then review your drafted project and will get your project started! Get stuck or need help? Email us at support@topcoder.com.`, }, submittedForReview: { title: 'Your project has been submitted for review', From 4d568ebce6e5fd3138d467bad3b600189a6ed015 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Thu, 24 Jan 2019 14:42:10 +0530 Subject: [PATCH 4/6] trying to fix the error in building --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ea9e3a7..b0689c8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ jobs: command: | echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add - - sudo apt-get update + sudo apt-get update --fix-missing sudo apt-get install rabbitmq-server sudo service rabbitmq-server start sudo cp local/rabbitmq_delayed_message_exchange-0.0.1.ez /usr/lib/rabbitmq/lib/rabbitmq_server-*/plugins From fe58dad6531ac33f2bd99caef4fb6de08190a748 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Fri, 25 Jan 2019 08:56:22 +0530 Subject: [PATCH 5/6] unit tests fix --- src/test/app.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/app.test.js b/src/test/app.test.js index a8dca54..ecae876 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -303,8 +303,8 @@ describe('app', () => { it('should create `Project.Created` notification', (done) => { sendTestEvent(sampleEvents.draftCreated, 'project.draft-created'); setTimeout(() => { - const expectedTitle = 'Your project has been created, and we\'re ready for your specification'; - const expectedBody = 'Hello, Coder here! Your project \'test\' has been drafted. If you have your requirements documented, just verify it against our checklist and then upload it on the Scope section. Once you\'ve finalized your scope, select the "Submit for Review" button. Topcoder will then review your drafted project and will assign a manager to get your delivery in-progress! Get stuck or need help? Email us at support@topcoder.com.'; + const expectedTitle = 'Share requirements and submit your draft project for review.'; + const expectedBody = 'Your project \'test\' has been drafted. If you have requirements documented, share them for review under the Files or Links section. Once you’re ready, click the "Submit for Review" button. Topcoder will then review your drafted project and will get your project started! Get stuck or need help? Email us at support@topcoder.com.'; const params = spy.lastCall.args; assert.equal(params[2], expectedTitle); assert.equal(params[3], expectedBody); From 73d6bff0c4f749a50f432054eb68fff88684a873 Mon Sep 17 00:00:00 2001 From: Samir Date: Mon, 28 Jan 2019 18:27:30 +0100 Subject: [PATCH 6/6] add environment variables to deploy.sh and circle config --- .circleci/config.yml | 5 +++++ deploy.sh | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b0689c8..aff788b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,6 +8,11 @@ defaults: &defaults LOG_LEVEL: debug AUTH_DOMAIN: topcoder-dev.com AUTH_SECRET: secret + API_URL_PROJECTS: http://localhost:3001/v4/projects + API_URL_MEMBERS: http://localhost:3001/v3/members + API_URL_USERS: http://localhost:3001/v3/users + API_URL_AUTHORIZATIONS: http://localhost:3001/v3/authorizations + API_URL_TOPICS: http://localhost:3001/v5/topics jobs: test: diff --git a/deploy.sh b/deploy.sh index d59a533..5dfa4a6 100755 --- a/deploy.sh +++ b/deploy.sh @@ -86,6 +86,26 @@ make_task_def(){ { "name": "AUTH0_PROXY_SERVER_URL", "value": "%s" + }, + { + "name": "API_URL_PROJECTS", + "value": "%s" + }, + { + "name": "API_URL_MEMBERS", + "value": "%s" + }, + { + "name": "API_URL_USERS", + "value": "%s" + }, + { + "name": "API_URL_AUTHORIZATIONS", + "value": "%s" + }, + { + "name": "API_URL_TOPICS", + "value": "%s" } ], "logConfiguration": { @@ -108,6 +128,11 @@ make_task_def(){ AUTH0_CLIENT_ID=$(eval "echo \$${ENV}_AUTH0_CLIENT_ID") AUTH0_CLIENT_SECRET=$(eval "echo \$${ENV}_AUTH0_CLIENT_SECRET") AUTH0_PROXY_SERVER_URL=$(eval "echo \$${ENV}_AUTH0_PROXY_SERVER_URL") + API_URL_PROJECTS=$(eval "echo \$${ENV}_API_URL_PROJECTS") + API_URL_MEMBERS=$(eval "echo \$${ENV}_API_URL_MEMBERS") + API_URL_USERS=$(eval "echo \$${ENV}_API_URL_USERS") + API_URL_AUTHORIZATIONS=$(eval "echo \$${ENV}_API_URL_AUTHORIZATIONS") + API_URL_TOPICS=$(eval "echo \$${ENV}_API_URL_TOPICS") if [ "$ENV" = "PROD" ]; then NODE_ENV=production @@ -115,7 +140,7 @@ make_task_def(){ NODE_ENV=development fi - task_def=$(printf "$task_template" $ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $CIRCLE_SHA1 $NODE_ENV $LOG_LEVEL $CAPTURE_LOGS $LOGENTRIES_TOKEN $RABBITMQ_URL $TC_SLACK_WEBHOOK_URL "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME "$AUTH0_PROXY_SERVER_URL" $AWS_ECS_CLUSTER $AWS_REGION $NODE_ENV) + task_def=$(printf "$task_template" $ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $CIRCLE_SHA1 $NODE_ENV $LOG_LEVEL $CAPTURE_LOGS $LOGENTRIES_TOKEN $RABBITMQ_URL $TC_SLACK_WEBHOOK_URL "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME "$AUTH0_PROXY_SERVER_URL" "$API_URL_PROJECTS" "$API_URL_MEMBERS" "$API_URL_USERS" "$API_URL_AUTHORIZATIONS" "$API_URL_TOPICS" $AWS_ECS_CLUSTER $AWS_REGION $NODE_ENV) } push_ecr_image(){