Skip to content

Commit 1a7e548

Browse files
lunnyappleboy
authored andcommitted
Add insecure https support (#4)
1 parent 180dadc commit 1a7e548

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ func main() {
4747
Usage: "create a draft release",
4848
EnvVar: "PLUGIN_DRAFT,GITEA_RELEASE_DRAFT",
4949
},
50+
cli.BoolFlag{
51+
Name: "insecure",
52+
Usage: "visit base-url via insecure https protocol",
53+
EnvVar: "PLUGIN_INSECURE,GITEA_RELEASE_INSECURE",
54+
},
5055
cli.BoolFlag{
5156
Name: "prerelease",
5257
Usage: "set the release as prerelease",
@@ -126,6 +131,7 @@ func run(c *cli.Context) error {
126131
Draft: c.Bool("draft"),
127132
PreRelease: c.Bool("prerelease"),
128133
BaseURL: c.String("base-url"),
134+
Insecure: c.Bool("insecure"),
129135
Title: c.String("title"),
130136
Note: c.String("note"),
131137
},

plugin.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package main
22

33
import (
4+
"crypto/tls"
45
"fmt"
6+
"io/ioutil"
7+
"net/http"
8+
"net/http/cookiejar"
9+
"os"
510
"path/filepath"
611
"strings"
712

813
"code.gitea.io/sdk/gitea"
9-
"io/ioutil"
10-
"os"
1114
)
1215

1316
type (
@@ -31,6 +34,7 @@ type (
3134
Checksum []string
3235
Draft bool
3336
PreRelease bool
37+
Insecure bool
3438
BaseURL string
3539
Title string
3640
Note string
@@ -108,6 +112,18 @@ func (p Plugin) Exec() error {
108112

109113
client := gitea.NewClient(p.Config.BaseURL, p.Config.APIKey)
110114

115+
if p.Config.Insecure {
116+
cookieJar, _ := cookiejar.New(nil)
117+
118+
var insecureClient = &http.Client{
119+
Jar: cookieJar,
120+
Transport: &http.Transport{
121+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
122+
},
123+
}
124+
client.SetHTTPClient(insecureClient)
125+
}
126+
111127
rc := releaseClient{
112128
Client: client,
113129
Owner: p.Repo.Owner,

0 commit comments

Comments
 (0)