Merge pull request #15 from sinotaotao/14-SSLVerifyOption
Add an option like git config `sslVerify`
This commit is contained in:
commit
052e132d32
@ -93,6 +93,12 @@
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "The repository name."
|
||||
},
|
||||
"gitea.sslVerify": {
|
||||
"scope": "resource",
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "true=Stop when cannot verify SSL certificate, false=Continue any way. Like git config 'sslVerify'."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ interface ConfigStorage {
|
||||
instanceURL: string;
|
||||
owner: string;
|
||||
repo: string;
|
||||
sslVerify: boolean;
|
||||
}
|
||||
|
||||
export interface ConfigTypes extends ConfigStorage {
|
||||
@ -69,4 +70,11 @@ export class Config implements ConfigTypes {
|
||||
public get repoApiUrl() {
|
||||
return this.instanceURL + '/api/v1/repos/' + this.owner + '/' + this.repo + '/issues';
|
||||
}
|
||||
|
||||
public set sslVerify(value){
|
||||
this.storage.update('sslVerify', value);
|
||||
}
|
||||
public get sslVerify(){
|
||||
return this.loadConfigValue('sslVerify', 'boolean')
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import axios from 'axios';
|
||||
import * as vscode from 'vscode';
|
||||
import * as https from 'https';
|
||||
|
||||
const marked = require('marked');
|
||||
import { Issue } from './issue';
|
||||
@ -36,9 +37,15 @@ export class OpenIssuesProvider implements vscode.TreeDataProvider<Issue> {
|
||||
const repoUri = config.repoApiUrl;
|
||||
const token = config.token;
|
||||
let stop = false;
|
||||
|
||||
const agent = new https.Agent({
|
||||
// if true, stop when can't verify ssl
|
||||
rejectUnauthorized: config.sslVerify,
|
||||
});
|
||||
|
||||
for (let i = 0; i !== 10; i++) {
|
||||
await axios
|
||||
.get(repoUri + '?page=' + i, { headers: { Authorization: 'token ' + token } })
|
||||
.get(repoUri + '?page=' + i, { headers: { Authorization: 'token ' + token }, httpsAgent: agent })
|
||||
.then((res) => {
|
||||
if (res.data.length === 0) {
|
||||
stop = true;
|
||||
@ -88,9 +95,15 @@ export class ClosedIssuesProvider implements vscode.TreeDataProvider<Issue> {
|
||||
const repoUri = config.repoApiUrl;
|
||||
const token = config.token;
|
||||
let stop = false;
|
||||
|
||||
const agent = new https.Agent({
|
||||
// if true, stop when can't verify ssl
|
||||
rejectUnauthorized: config.sslVerify,
|
||||
});
|
||||
|
||||
for (let i = 0; i !== 10; i++) {
|
||||
await axios
|
||||
.get(repoUri + '?state=closed&page=' + i, { headers: { Authorization: 'token ' + token } })
|
||||
.get(repoUri + '?state=closed&page=' + i, { headers: { Authorization: 'token ' + token } , httpsAgent: agent} )
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
if (res.data.length === 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user