Skip to content

Commit

Permalink
feat: use @probot/get-private-key (#1414)
Browse files Browse the repository at this point in the history
part of #1309
  • Loading branch information
gr2m committed Nov 18, 2020
1 parent 0527b98 commit 47d9f3a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 236 deletions.
6 changes: 3 additions & 3 deletions bin/probot-receive.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require("dotenv").config();
const path = require("path");
const uuid = require("uuid");
const program = require("commander");
const { getPrivateKey } = require("@probot/get-private-key");

const { findPrivateKey } = require("../lib/helpers/get-private-key");
const {
logWarningsForObsoleteEnvironmentVariables,
} = require("../lib/helpers/log-warnings-for-obsolete-environment-variables");
Expand Down Expand Up @@ -36,7 +36,7 @@ program
.option(
"-P, --private-key <file>",
"Path to certificate of the GitHub App",
findPrivateKey
getPrivateKey
)
.parse(process.argv);

Expand All @@ -46,7 +46,7 @@ if (!program.event || !program.payloadPath) {
program.help();
}

const privateKey = findPrivateKey();
const privateKey = getPrivateKey();
if (!githubToken && (!program.app || !privateKey)) {
console.warn(
"No token specified and no certificate found, which means you will not be able to do authenticated requests to GitHub"
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@octokit/request": "^5.1.0",
"@octokit/types": "^5.0.1",
"@octokit/webhooks": "^7.15.0",
"@probot/get-private-key": "^1.0.0",
"@probot/octokit-plugin-config": "^1.0.0",
"@probot/pino": "^1.1.2",
"@types/express": "^4.17.2",
Expand Down
69 changes: 0 additions & 69 deletions src/helpers/get-private-key.ts

This file was deleted.

10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
// tslint:disable-next-line: no-var-requires
require("dotenv").config();

import { Server } from "http";

import express from "express";
import Redis from "ioredis";
import LRUCache from "lru-cache";
import { Deprecation } from "deprecation";
import pinoHttp from "pino-http";
import { getPrivateKey } from "@probot/get-private-key";

import type { WebhookEvent, Webhooks } from "@octokit/webhooks";
import type { Logger } from "pino";

import { Server } from "http";
import { Application } from "./application";
import { setupAppFactory } from "./apps/setup";
import { Context, WebhookPayloadWithRepository } from "./context";
import { ProbotOctokit } from "./octokit/probot-octokit";
import { getLog } from "./helpers/get-log";
import { findPrivateKey } from "./helpers/get-private-key";
import { resolveAppFunction } from "./helpers/resolve-app-function";
import { createServer } from "./server/create-server";
import { createWebhookProxy } from "./helpers/webhook-proxy";
Expand Down Expand Up @@ -110,7 +111,8 @@ export class Probot {
.parse(appFn);

return {
privateKey: findPrivateKey(program.privateKey) || undefined,
privateKey:
getPrivateKey({ filepath: program.privateKey }) || undefined,
id: program.app,
port: program.port,
host: program.host,
Expand All @@ -119,7 +121,7 @@ export class Probot {
webhookProxy: program.webhookProxy,
};
}
const privateKey = findPrivateKey();
const privateKey = getPrivateKey();
return {
privateKey: (privateKey && privateKey.toString()) || undefined,
id: Number(process.env.APP_ID),
Expand Down
160 changes: 0 additions & 160 deletions test/private-key.test.ts

This file was deleted.

0 comments on commit 47d9f3a

Please sign in to comment.