1
0
Fork 0

fix(remote/github): use data type for auth method

This commit is contained in:
ssube 2020-08-14 18:18:13 -05:00
parent 24e0e67cdf
commit 39a7091ac3
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 23 additions and 16 deletions

View File

@ -74,7 +74,7 @@ For app authentication:
- `id`: application ID
- `installationId`: installation ID
- `privateKey`: application key material
- `type`: `installation`
- `type`: `app`
#### Gitlab Remote

View File

@ -24,21 +24,28 @@ export class GithubRemote implements Remote {
public async connect() {
this.options.logger.info('connecting to github');
if (doesExist(this.options.data.installationId)) {
this.options.logger.info('using app auth');
this.request = new Octokit({
auth: {
id: parseInt(mustExist(this.options.data.id), 10),
installationId: parseInt(mustExist(this.options.data.installationId), 10),
privateKey: mustExist(this.options.data.privateKey),
},
authStrategy: createAppAuth,
});
} else {
this.options.logger.info('using token auth');
this.request = new Octokit({
auth: mustExist(this.options.data.token),
});
const type = mustExist(this.options.data.type);
switch (type) {
case 'app':
this.options.logger.info('using app auth');
this.request = new Octokit({
auth: {
id: parseInt(mustExist(this.options.data.id), 10),
installationId: parseInt(mustExist(this.options.data.installationId), 10),
privateKey: mustExist(this.options.data.privateKey),
},
authStrategy: createAppAuth,
});
break;
case 'token':
this.options.logger.info('using token auth');
this.request = new Octokit({
auth: mustExist(this.options.data.token),
});
break;
default:
throw new InvalidArgumentError('unknown authentication type');
}
}