Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[download-microservice] Auth All GitHub Requests #131

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!");
confused-Techie marked this conversation as resolved.
Show resolved Hide resolved
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
Loading