2 Commits

Author SHA1 Message Date
Lunny Xiao 1a7e5488a0 Add insecure https support (#4) 2018-03-28 09:55:21 +08:00
Thomas Boerger 180dadcd0e Dropped comments from gopkg config 2018-03-16 13:23:00 +01:00
3 changed files with 24 additions and 29 deletions
-27
View File
@@ -1,30 +1,3 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
[[constraint]]
branch = "master"
name = "code.gitea.io/sdk"
+6
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"),
},
+18 -2
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,