0
0
mirror of https://github.com/thegeeklab/wp-gitea-release.git synced 2024-06-02 18:29:43 +02:00

Add insecure https support (#4)

This commit is contained in:
Lunny Xiao 2018-03-28 09:55:21 +08:00 committed by Bo-Yi Wu
parent 180dadcd0e
commit 1a7e5488a0
2 changed files with 24 additions and 2 deletions

View File

@ -47,6 +47,11 @@ func main() {
Usage: "create a draft release",
EnvVar: "PLUGIN_DRAFT,GITEA_RELEASE_DRAFT",
},
cli.BoolFlag{
Name: "insecure",
Usage: "visit base-url via insecure https protocol",
EnvVar: "PLUGIN_INSECURE,GITEA_RELEASE_INSECURE",
},
cli.BoolFlag{
Name: "prerelease",
Usage: "set the release as prerelease",
@ -126,6 +131,7 @@ func run(c *cli.Context) error {
Draft: c.Bool("draft"),
PreRelease: c.Bool("prerelease"),
BaseURL: c.String("base-url"),
Insecure: c.Bool("insecure"),
Title: c.String("title"),
Note: c.String("note"),
},

View File

@ -1,13 +1,16 @@
package main
import (
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"os"
"path/filepath"
"strings"
"code.gitea.io/sdk/gitea"
"io/ioutil"
"os"
)
type (
@ -31,6 +34,7 @@ type (
Checksum []string
Draft bool
PreRelease bool
Insecure bool
BaseURL string
Title string
Note string
@ -108,6 +112,18 @@ func (p Plugin) Exec() error {
client := gitea.NewClient(p.Config.BaseURL, p.Config.APIKey)
if p.Config.Insecure {
cookieJar, _ := cookiejar.New(nil)
var insecureClient = &http.Client{
Jar: cookieJar,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
client.SetHTTPClient(insecureClient)
}
rc := releaseClient{
Client: client,
Owner: p.Repo.Owner,