-
Notifications
You must be signed in to change notification settings - Fork 176
Expand file tree
/
Copy pathenvironmentSecretsNode.ts
More file actions
41 lines (34 loc) · 1.4 KB
/
environmentSecretsNode.ts
File metadata and controls
41 lines (34 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as vscode from "vscode";
import {GitHubRepoContext} from "../../git/repository";
import {Environment} from "../../model";
import {EmptyNode} from "./emptyNode";
import {SecretNode} from "./secretNode";
export type EnvironmentSecretsCommandArgs = Pick<EnvironmentSecretsNode, "gitHubRepoContext" | "environment">;
export class EnvironmentSecretsNode extends vscode.TreeItem {
constructor(public readonly gitHubRepoContext: GitHubRepoContext, public readonly environment: Environment) {
super("Secrets", vscode.TreeItemCollapsibleState.Collapsed);
this.iconPath = new vscode.ThemeIcon("lock");
this.contextValue = "environment-secrets";
}
async getSecrets(): Promise<(SecretNode | EmptyNode)[]> {
let secrets: SecretNode[] = [];
try {
secrets = await this.gitHubRepoContext.client.paginate(
this.gitHubRepoContext.client.actions.listEnvironmentSecrets,
{
owner: this.gitHubRepoContext.owner,
repo: this.gitHubRepoContext.name,
environment_name: this.environment.name,
per_page: 100
},
response => response.data.map(s => new SecretNode(this.gitHubRepoContext, s, this.environment))
);
} catch (e) {
await vscode.window.showErrorMessage((e as Error).message);
}
if (!secrets || secrets.length === 0) {
return [new EmptyNode("No environment secrets defined")];
}
return secrets;
}
}