mirror of
https://github.com/thegeeklab/wp-gitea-release.git
synced 2024-11-24 13:00:40 +00:00
Add insecure https support (#4)
This commit is contained in:
parent
180dadcd0e
commit
1a7e5488a0
6
main.go
6
main.go
@ -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"),
|
||||
},
|
||||
|
20
plugin.go
20
plugin.go
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user