Skip to content

Commit

Permalink
Strictly prefer camel case
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry Gordon committed Sep 13, 2021
1 parent bddcf37 commit 51faae9
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 47 deletions.
4 changes: 2 additions & 2 deletions __fixtures__/events/default.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"inputs": {
"jobID": "1",
"jobId": "1",
"jobToken": "xxx",
"credentialsToken": "yyy",
"dependabotAPIURL": "http://localhost:9000"
"dependabotApiUrl": "http://localhost:9000"
},
"ref": "main",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/dependabot-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ describe('APIClient', () => {
get: jest.fn()
}
const api = new APIClient(mockAxios, {
jobID: 1,
jobId: 1,
jobToken: 'xxx',
credentialsToken: 'yyy',
dependabotAPIURL: 'https://localhost'
dependabotApiUrl: 'https://localhost'
})
beforeEach(jest.clearAllMocks)

Expand Down
8 changes: 4 additions & 4 deletions __tests__/inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ test('loads dynamic', () => {
ctx.eventName = 'dynamic'
ctx.payload = {
inputs: {
jobID: 1,
jobId: 1,
jobToken: 'xxx',
credentialsToken: 'yyy'
}
}

const params = getJobParameters(ctx)
expect(params?.jobID).toEqual(1)
expect(params?.jobId).toEqual(1)
expect(params?.jobToken).toEqual('xxx')
expect(params?.credentialsToken).toEqual('yyy')
})
Expand All @@ -31,14 +31,14 @@ test('loads workflow_dispatch', () => {
ctx.eventName = 'workflow_dispatch'
ctx.payload = {
inputs: {
jobID: '1',
jobId: '1',
jobToken: 'xxx',
credentialsToken: 'yyy'
}
}

const params = getJobParameters(ctx)
expect(params?.jobID).toEqual(1)
expect(params?.jobId).toEqual(1)
expect(params?.jobToken).toEqual('xxx')
expect(params?.credentialsToken).toEqual('yyy')
})
2 changes: 1 addition & 1 deletion __tests__/updater-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Updater', () => {

// To run the js-code itself against API:
// const params = {
// jobID: 1,
// jobId: 1,
// jobToken: 'xxx',
// credentialsToken: 'xxx',
// dependabotAPI: 'http://host.docker.internal:3001'
Expand Down
4 changes: 2 additions & 2 deletions __tests__/updater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ describe('Updater', () => {
getJobDetails: jest.fn(),
getCredentials: jest.fn(),
params: {
jobID: 1,
jobId: 1,
jobToken: process.env.JOB_TOKEN,
credentialsToken: process.env.CREDENTIALS_TOKEN,
dependabotAPIURL: 'http://host.docker.internal:3001'
dependabotApiUrl: 'http://host.docker.internal:3001'
}
}
const mockJobDetails: any = {
Expand Down
34 changes: 17 additions & 17 deletions dist/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/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions script/hack-event.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"action": "on-demand-test",
"branch": "master",
"client_payload": {
"dependabotAPIURL": "https://3c3fcfad18d1.ngrok.io",
"jobID": "8",
"dependabotApiUrl": "https://3c3fcfad18d1.ngrok.io",
"jobId": "8",
"jobToken": "QkNM+m1lDFieJ0V6DAwUY+hG6PUKItjuS7EApTVsTQw=",
"credentialsToken": "hMAqnnY+CJGUCQjKRUzSZnR+DnbW5YEA5nL2xh8zovk=",
"updaterImage": "docker.io/library/dependabot-updater:latest",
Expand Down
12 changes: 6 additions & 6 deletions src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {AxiosInstance} from 'axios'
// JobParameters are the parameters to execute a job
export class JobParameters {
constructor(
readonly jobID: number,
readonly jobId: number,
readonly jobToken: string,
readonly credentialsToken: string,
readonly dependabotAPIURL: string
readonly dependabotApiUrl: string
) {}
}

Expand Down Expand Up @@ -45,7 +45,7 @@ export class APIClient {
) {}

async getJobDetails(): Promise<JobDetails> {
const detailsURL = `/update_jobs/${this.params.jobID}/details`
const detailsURL = `/update_jobs/${this.params.jobId}/details`
const res = await this.client.get(detailsURL, {
headers: {Authorization: this.params.jobToken}
})
Expand All @@ -57,7 +57,7 @@ export class APIClient {
}

async getCredentials(): Promise<Credential[]> {
const credentialsURL = `/update_jobs/${this.params.jobID}/credentials`
const credentialsURL = `/update_jobs/${this.params.jobId}/credentials`
const res = await this.client.get(credentialsURL, {
headers: {Authorization: this.params.credentialsToken}
})
Expand All @@ -69,7 +69,7 @@ export class APIClient {
}

async reportJobError(error: JobError): Promise<void> {
const recordErrorURL = `/update_jobs/${this.params.jobID}/record_update_job_error`
const recordErrorURL = `/update_jobs/${this.params.jobId}/record_update_job_error`
const res = await this.client.post(recordErrorURL, error, {
headers: {Authorization: this.params.jobToken}
})
Expand All @@ -81,7 +81,7 @@ export class APIClient {
}

async markJobAsProcessed(): Promise<void> {
const markAsProcessedURL = `/update_jobs/${this.params.jobID}/mark_as_processed`
const markAsProcessedURL = `/update_jobs/${this.params.jobId}/mark_as_processed`
const res = await this.client.get(markAsProcessedURL, {
headers: {Authorization: this.params.credentialsToken}
})
Expand Down
4 changes: 2 additions & 2 deletions src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export function getJobParameters(ctx: Context): JobParameters | null {
function fromWorkflowInputs(ctx: Context): JobParameters {
const evt = ctx.payload as WorkflowDispatchEvent
return new JobParameters(
parseInt(evt.inputs.jobID as string, 10),
parseInt(evt.inputs.jobId as string, 10),
evt.inputs.jobToken as string,
evt.inputs.credentialsToken as string,
evt.inputs.dependabotAPIURL as string
evt.inputs.dependabotApiUrl as string
)
}
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function run(context: Context): Promise<void> {
core.setSecret(params.jobToken)
core.setSecret(params.credentialsToken)

const client = axios.create({baseURL: params.dependabotAPIURL})
const client = axios.create({baseURL: params.dependabotApiUrl})
const apiClient = new APIClient(client, params)

try {
Expand Down
8 changes: 4 additions & 4 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ export class ProxyBuilder {

private buildProxyConfig(
credentials: Credential[],
jobID: string
jobId: string
): ProxyConfig {
const ca = this.generateCertificateAuthority()
const password = crypto.randomBytes(20).toString('hex')
const proxy_auth: BasicAuthCredentials = {
username: `${jobID}`,
username: `${jobId}`,
password
}

Expand Down Expand Up @@ -167,7 +167,7 @@ export class ProxyBuilder {
}

private async createContainer(
jobID: string,
jobId: string,
containerName: string,
networkName: string
): Promise<Container> {
Expand All @@ -176,7 +176,7 @@ export class ProxyBuilder {
name: containerName,
AttachStdout: true,
AttachStderr: true,
Env: [`JOB_ID=${jobID}`],
Env: [`JOB_ID=${jobId}`],
Entrypoint: [
'sh',
'-c',
Expand Down
6 changes: 3 additions & 3 deletions src/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class Updater {
proxy: Proxy,
files: FetchedFiles
): Promise<void> {
core.info(`Running update job ${this.apiClient.params.jobID}`)
core.info(`Running update job ${this.apiClient.params.jobId}`)
const container = await this.createContainer(proxy, 'update_files')
const containerInput: FileUpdaterInput = {
base_commit_sha: files.base_commit_sha,
Expand Down Expand Up @@ -140,12 +140,12 @@ export class Updater {
AttachStdout: true,
AttachStderr: true,
Env: [
`DEPENDABOT_JOB_ID=${this.apiClient.params.jobID}`,
`DEPENDABOT_JOB_ID=${this.apiClient.params.jobId}`,
`DEPENDABOT_JOB_TOKEN=${this.apiClient.params.jobToken}`,
`DEPENDABOT_JOB_PATH=${JOB_INPUT_PATH}/${JOB_INPUT_FILENAME}`,
`DEPENDABOT_OUTPUT_PATH=${JOB_OUTPUT_PATH}/${JOB_OUTPUT_FILENAME}`,
`DEPENDABOT_REPO_CONTENTS_PATH=${REPO_CONTENTS_PATH}`,
`DEPENDABOT_API_URL=${this.apiClient.params.dependabotAPIURL}`,
`DEPENDABOT_API_URL=${this.apiClient.params.dependabotApiUrl}`,
`SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt`,
`http_proxy=${proxy.url}`,
`HTTP_PROXY=${proxy.url}`,
Expand Down

0 comments on commit 51faae9

Please sign in to comment.