From 8d626f40c2db9faf098f3c72b6f72e8730dba3cc Mon Sep 17 00:00:00 2001 From: Mikael Brevik Date: Mon, 9 Nov 2020 13:59:42 +0100 Subject: [PATCH 1/2] feat: adds ticket invite key env to build --- Dockerfile | 1 + cloudbuild.yaml | 8 +++++++- src/api/enrollment/index.ts | 3 ++- src/config/env.ts | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/config/env.ts diff --git a/Dockerfile b/Dockerfile index 06219f43..1dcc68dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,5 @@ COPY package*.json ./ RUN npm install --production ENV NODE_ENV=production +ENV TICKET_INVITE_KEY=$ticket_invite_key CMD npm start \ No newline at end of file diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 1c4f6e36..b9f1dca1 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,6 +1,12 @@ steps: - name: 'gcr.io/cloud-builders/docker' - args: ['build', '-t', 'gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA', '.'] + args: + - 'build' + - '--build-arg' + - 'ticket_invite_key=${_TICKET_INVITE_KEY}' + - '-t' + - 'gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA' + - '.' timeout: 25m - name: 'gcr.io/cloud-builders/docker' args: ['push', 'gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA'] diff --git a/src/api/enrollment/index.ts b/src/api/enrollment/index.ts index fde1a6f4..63231879 100644 --- a/src/api/enrollment/index.ts +++ b/src/api/enrollment/index.ts @@ -2,6 +2,7 @@ import Hapi from '@hapi/hapi'; import { EnrollmentQuery } from '../../service/types'; import { postEnrollmentGroupRequest } from './schema'; import * as Boom from '@hapi/boom'; +import { TICKET_INVITE_KEY } from '../../config/env'; export default (server: Hapi.Server) => () => { server.route({ @@ -15,7 +16,7 @@ export default (server: Hapi.Server) => () => { handler: async (request, h) => { const query = (request.query as unknown) as EnrollmentQuery; - if (query.inviteKey === 'hurrafordeg') { + if (TICKET_INVITE_KEY && TICKET_INVITE_KEY === query.inviteKey) { return { status: 'ok', groups: ['ticketing_group'] }; } diff --git a/src/config/env.ts b/src/config/env.ts new file mode 100644 index 00000000..e90779a6 --- /dev/null +++ b/src/config/env.ts @@ -0,0 +1,2 @@ +export const TICKET_INVITE_KEY: string | undefined = + process.env.TICKET_INVITE_KEY; From e9bec7542f64a764e523793346c5a16277709496 Mon Sep 17 00:00:00 2001 From: Mikael Brevik Date: Mon, 9 Nov 2020 14:41:45 +0100 Subject: [PATCH 2/2] removes env handling --- Dockerfile | 1 - cloudbuild.yaml | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1dcc68dc..06219f43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,5 +11,4 @@ COPY package*.json ./ RUN npm install --production ENV NODE_ENV=production -ENV TICKET_INVITE_KEY=$ticket_invite_key CMD npm start \ No newline at end of file diff --git a/cloudbuild.yaml b/cloudbuild.yaml index b9f1dca1..1c4f6e36 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -1,12 +1,6 @@ steps: - name: 'gcr.io/cloud-builders/docker' - args: - - 'build' - - '--build-arg' - - 'ticket_invite_key=${_TICKET_INVITE_KEY}' - - '-t' - - 'gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA' - - '.' + args: ['build', '-t', 'gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA', '.'] timeout: 25m - name: 'gcr.io/cloud-builders/docker' args: ['push', 'gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA']