Skip to content

Commit

Permalink
remove job token feature flag code (#1280)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecoffman authored Aug 16, 2024
1 parent 300639d commit 61e94b3
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 54 deletions.
8 changes: 1 addition & 7 deletions __tests__/proxy-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ integration('ProxyBuilder', () => {
]

const cachedMode = true
const moveJobToken = true
const builder = new ProxyBuilder(
docker,
PROXY_IMAGE_NAME,
cachedMode,
moveJobToken
)
const builder = new ProxyBuilder(docker, PROXY_IMAGE_NAME, cachedMode)

beforeAll(async () => {
await ImageService.pull(PROXY_IMAGE_NAME)
Expand Down
4 changes: 1 addition & 3 deletions __tests__/updater-builder-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ integration('UpdaterBuilder', () => {
fs.mkdirSync(repoPath)

const cachedMode = true
const moveJobToken = true
const proxy = await new ProxyBuilder(
docker,
PROXY_IMAGE_NAME,
cachedMode,
moveJobToken
cachedMode
).run(1, dependabotApiUrl, jobToken, credentials)
await proxy.container.start()
const input = {job: details}
Expand Down
2 changes: 1 addition & 1 deletion dist/cleanup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 5 additions & 18 deletions dist/main/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker/Dockerfile.proxy
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/github/dependabot-update-job-proxy/dependabot-update-job-proxy:v2.0.20240815124847@sha256:44e6e58b0f8c0867853fc5a287133d1041d39bb14bd2855322959062cdfc5fb0
FROM ghcr.io/github/dependabot-update-job-proxy/dependabot-update-job-proxy:v2.0.20240815143114@sha256:6267303ea702a93e76d0e6d1e8d86c04330bea2acdad073c04787ef5e1bfc111
4 changes: 2 additions & 2 deletions docker/containers.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"proxy": "ghcr.io/github/dependabot-update-job-proxy/dependabot-update-job-proxy:v2.0.20240815124847@sha256:44e6e58b0f8c0867853fc5a287133d1041d39bb14bd2855322959062cdfc5fb0",
"proxy": "ghcr.io/github/dependabot-update-job-proxy/dependabot-update-job-proxy:v2.0.20240815143114@sha256:6267303ea702a93e76d0e6d1e8d86c04330bea2acdad073c04787ef5e1bfc111",
"bundler": "ghcr.io/dependabot/dependabot-updater-bundler:v2.0.20240628234530@sha256:2e094e732d5b7fd71695aaa3bbfd9e0cefe1cd22d40e228d3071e46b65995efe",
"cargo": "ghcr.io/dependabot/dependabot-updater-cargo:v2.0.20240628234530@sha256:824fdd484435cc9625c86f184512aea69aed0d369450c3a1a734d70f79f86837",
"composer": "ghcr.io/dependabot/dependabot-updater-composer:v2.0.20240628234530@sha256:0a8500614da4d0ea31128224037a80490754ae9d30b0cf6c682c969d658a1558",
Expand All @@ -17,4 +17,4 @@
"pip": "ghcr.io/dependabot/dependabot-updater-pip:v2.0.20240628234530@sha256:35933a960d16b0d59e2a8a1fdc104085e2f93e166ffaeb6044dcf82422639a55",
"swift": "ghcr.io/dependabot/dependabot-updater-swift:v2.0.20240709134805@sha256:4a255b94550d2fc8735b36fbcc7c8a7961be5080892d84e22cf82039bf0889a0",
"terraform": "ghcr.io/dependabot/dependabot-updater-terraform:v2.0.20240628234530@sha256:ecf89152a44ffd6835f3b36473abcffa8725c3f853f583a6ca9c5c1152f2d0b2"
}
}
4 changes: 1 addition & 3 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ export class ProxyBuilder {
constructor(
private readonly docker: Docker,
private readonly proxyImage: string,
private readonly cachedMode: boolean,
private readonly moveJobToken: boolean
private readonly cachedMode: boolean
) {}

async run(
Expand Down Expand Up @@ -205,7 +204,6 @@ export class ProxyBuilder {
`JOB_ID=${jobId}`,
`JOB_TOKEN=${jobToken}`,
`PROXY_CACHE=${this.cachedMode ? 'true' : 'false'}`,
`MOVE_JOB_TOKEN=${this.moveJobToken ? 'true' : 'false'}`,
`DEPENDABOT_API_URL=${dependabotApiUrl}`
],
Entrypoint: [
Expand Down
15 changes: 1 addition & 14 deletions src/updater-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,12 @@ export class UpdaterBuilder {
private readonly updaterImage: string
) {}

private setDependabotJobToken(): string {
const jobToken =
this.jobParams.jobToken || process.env.GITHUB_DEPENDABOT_JOB_TOKEN || ''

// The job token has been moved to the proxy container.
if (this.input.job.experiments?.hasOwnProperty('move-job-token') === true) {
return ''
}

return jobToken
}

async run(containerName: string): Promise<Container> {
const cmd = `/usr/sbin/update-ca-certificates &&\
mkdir -p ${JOB_OUTPUT_PATH} &&\
$DEPENDABOT_HOME/dependabot-updater/bin/run fetch_files &&\
$DEPENDABOT_HOME/dependabot-updater/bin/run update_files`

const dependabotJobToken = this.setDependabotJobToken()
const proxyUrl = await this.proxy.url()
const container = await this.docker.createContainer({
Image: this.updaterImage,
Expand All @@ -53,7 +40,7 @@ export class UpdaterBuilder {
Env: [
`GITHUB_ACTIONS=${process.env.GITHUB_ACTIONS}`,
`DEPENDABOT_JOB_ID=${this.jobParams.jobId}`,
`DEPENDABOT_JOB_TOKEN=${dependabotJobToken}`,
`DEPENDABOT_JOB_TOKEN=`,
`DEPENDABOT_JOB_PATH=${JOB_INPUT_PATH}/${JOB_INPUT_FILENAME}`,
`DEPENDABOT_OPEN_TIMEOUT_IN_SECONDS=15`,
`DEPENDABOT_OUTPUT_PATH=${JOB_OUTPUT_PATH}/${JOB_OUTPUT_FILENAME}`,
Expand Down
5 changes: 1 addition & 4 deletions src/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ export class Updater {

const cachedMode =
this.details.experiments?.hasOwnProperty('proxy-cached') === true
const moveJobToken =
this.details.experiments?.hasOwnProperty('move-job-token') === true

const proxyBuilder = new ProxyBuilder(
this.docker,
this.proxyImage,
cachedMode,
moveJobToken
cachedMode
)

const proxy = await proxyBuilder.run(
Expand Down

0 comments on commit 61e94b3

Please sign in to comment.