Skip to content

Commit 6e1c72c

Browse files
committed
Refactor runner interfaces: remove RunnerState interface and update imports in scale-down.ts
1 parent 1182c8b commit 6e1c72c

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lambdas/functions/control-plane/src/aws/runners.d.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ export interface RunnerList {
1313
runnerId?: string;
1414
}
1515

16-
export interface RunnerState {
17-
id: number;
18-
name: string;
19-
busy: boolean;
20-
status: string;
21-
}
22-
2316
export interface RunnerInfo {
2417
instanceId: string;
2518
launchTime?: Date;

lambdas/functions/control-plane/src/scale-runners/scale-down.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@ import moment from 'moment';
44

55
import { createGithubAppAuth, createGithubInstallationAuth, createOctokitClient } from '../github/auth';
66
import { bootTimeExceeded, listEC2Runners, tag, untag, terminateRunner } from './../aws/runners';
7-
import { RunnerInfo, RunnerList, RunnerState } from './../aws/runners.d';
7+
import { RunnerInfo, RunnerList } from './../aws/runners.d';
88
import { GhRunners, githubCache } from './cache';
99
import { ScalingDownConfig, getEvictionStrategy, getIdleRunnerCount } from './scale-down-config';
1010
import { metricGitHubAppRateLimit } from '../github/rate-limit';
1111
import { getGitHubEnterpriseApiUrl } from './scale-up';
12+
import { GetResponseDataTypeFromEndpointMethod } from '@octokit/types/dist-types/GetResponseTypeFromEndpointMethod';
1213

1314
const logger = createChildLogger('scale-down');
1415

16+
type OrgRunnerList = GetResponseDataTypeFromEndpointMethod<
17+
typeof Octokit.prototype.actions.listSelfHostedRunnersForOrg
18+
>;
19+
20+
type RepoRunnerList = GetResponseDataTypeFromEndpointMethod<
21+
typeof Octokit.prototype.actions.listSelfHostedRunnersForRepo
22+
>;
23+
24+
// Derive the shape of an individual runner
25+
type RunnerState = (OrgRunnerList | RepoRunnerList)['runners'][number];
1526

1627
async function getOrCreateOctokit(runner: RunnerInfo): Promise<Octokit> {
1728
const key = runner.owner;

0 commit comments

Comments
 (0)