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",
|
"type": "string",
|
||||||
"default": "",
|
"default": "",
|
||||||
"description": "The repository name."
|
"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;
|
instanceURL: string;
|
||||||
owner: string;
|
owner: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
|
sslVerify: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigTypes extends ConfigStorage {
|
export interface ConfigTypes extends ConfigStorage {
|
||||||
@ -69,4 +70,11 @@ export class Config implements ConfigTypes {
|
|||||||
public get repoApiUrl() {
|
public get repoApiUrl() {
|
||||||
return this.instanceURL + '/api/v1/repos/' + this.owner + '/' + this.repo + '/issues';
|
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 axios from 'axios';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
import * as https from 'https';
|
||||||
|
|
||||||
const marked = require('marked');
|
const marked = require('marked');
|
||||||
import { Issue } from './issue';
|
import { Issue } from './issue';
|
||||||
@ -36,9 +37,15 @@ export class OpenIssuesProvider implements vscode.TreeDataProvider<Issue> {
|
|||||||
const repoUri = config.repoApiUrl;
|
const repoUri = config.repoApiUrl;
|
||||||
const token = config.token;
|
const token = config.token;
|
||||||
let stop = false;
|
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++) {
|
for (let i = 0; i !== 10; i++) {
|
||||||
await axios
|
await axios
|
||||||
.get(repoUri + '?page=' + i, { headers: { Authorization: 'token ' + token } })
|
.get(repoUri + '?page=' + i, { headers: { Authorization: 'token ' + token }, httpsAgent: agent })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data.length === 0) {
|
if (res.data.length === 0) {
|
||||||
stop = true;
|
stop = true;
|
||||||
@ -88,9 +95,15 @@ export class ClosedIssuesProvider implements vscode.TreeDataProvider<Issue> {
|
|||||||
const repoUri = config.repoApiUrl;
|
const repoUri = config.repoApiUrl;
|
||||||
const token = config.token;
|
const token = config.token;
|
||||||
let stop = false;
|
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++) {
|
for (let i = 0; i !== 10; i++) {
|
||||||
await axios
|
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) => {
|
.then((res) => {
|
||||||
console.log(res.data);
|
console.log(res.data);
|
||||||
if (res.data.length === 0) {
|
if (res.data.length === 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user