Explicitly pass repository to feature flags constructor
As suggested in review: The `GITHUB_REPOSITORY` environment variable is only available on Actions. Passing it in explicitly avoids potentially crashing if this code is called from the runner.
This commit is contained in:
parent
621e0794ac
commit
5e87034b3b
9 changed files with 31 additions and 33 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { getApiClient, GitHubApiDetails } from "./api-client";
|
||||
import { Logger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import { RepositoryNwo } from "./repository";
|
||||
import * as util from "./util";
|
||||
|
||||
export interface FeatureFlags {
|
||||
|
|
@ -23,6 +23,7 @@ export class GitHubFeatureFlags implements FeatureFlags {
|
|||
constructor(
|
||||
private gitHubVersion: util.GitHubVersion,
|
||||
private apiDetails: GitHubApiDetails,
|
||||
private repositoryNwo: RepositoryNwo,
|
||||
private logger: Logger
|
||||
) {}
|
||||
|
||||
|
|
@ -62,15 +63,12 @@ export class GitHubFeatureFlags implements FeatureFlags {
|
|||
return {};
|
||||
}
|
||||
const client = getApiClient(this.apiDetails);
|
||||
const repositoryNwo = parseRepositoryNwo(
|
||||
util.getRequiredEnvParam("GITHUB_REPOSITORY")
|
||||
);
|
||||
try {
|
||||
const response = await client.request(
|
||||
"GET /repos/:owner/:repo/code-scanning/codeql-action/features",
|
||||
{
|
||||
owner: repositoryNwo.owner,
|
||||
repo: repositoryNwo.repo,
|
||||
owner: this.repositoryNwo.owner,
|
||||
repo: this.repositoryNwo.repo,
|
||||
}
|
||||
);
|
||||
return response.data;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue