Skip to content

Commit

Permalink
Merge pull request #131 from pulsar-edit/download/auth-requests
Browse files Browse the repository at this point in the history
[download-microservice] Auth All GitHub Requests
  • Loading branch information
confused-Techie authored Feb 1, 2024
2 parents 07cc9c6 + 56f80ba commit e88430e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions microservices/download/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@ metadata:
spec:
template:
spec:
serviceAccountName: [email protected]
containers:
- image: "us-west2-docker.pkg.dev/pulsar-357404/package-frontend/download:2.0.1"
env:
- name: GH_TOKEN_DOWNLOAD_MICROSERVICE
valueFrom:
secretKeyRef:
key: latest
name: GH_TOKEN_DOWNLOAD_MICROSERVICE
17 changes: 16 additions & 1 deletion microservices/download/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
const https = require("node:https");
let TOKEN = process.env.GH_TOKEN_DOWNLOAD_MICROSERVICE;

// Environment Variables Check

if (typeof TOKEN === "undefined") {
if (process.env.PULSAR_STATUS === "dev") {
// We are in dev mode, assign dev values
TOKEN = "123456";
} else {
// We are not in dev mode. Our secrets are gone and the application will fail to work
console.log("Missing Required Environment Variables! Something has gone wrong!");
process.exit(1);
}
}

function doRequest() {

Expand All @@ -8,7 +22,8 @@ function doRequest() {
method: 'GET',
headers: {
'Accept': 'application/vnd.github+json',
'User-Agent': 'pulsar-edit/package-frontend/microservices/download'
'User-Agent': 'pulsar-edit/package-frontend/microservices/download',
'Authorization': `Bearer ${TOKEN}`
}
};

Expand Down

0 comments on commit e88430e

Please sign in to comment.