diff --git a/main.go b/main.go index d4ec737..6205395 100644 --- a/main.go +++ b/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"), }, diff --git a/plugin.go b/plugin.go index ac0da4f..b59dfcc 100644 --- a/plugin.go +++ b/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,