feat: allow insecure connections on deployment to some self-hosted services

This commit is contained in:
Fu Diwei
2025-03-07 21:04:32 +08:00
parent 29dda4ec66
commit 1e2e88e299
33 changed files with 250 additions and 81 deletions

View File

@@ -2,6 +2,7 @@ package webhook
import (
"context"
"crypto/tls"
"encoding/json"
"strings"
"time"
@@ -19,6 +20,8 @@ type DeployerConfig struct {
WebhookUrl string `json:"webhookUrl"`
// Webhook 回调数据JSON 格式)。
WebhookData string `json:"webhookData,omitempty"`
// 是否允许不安全的连接。
AllowInsecureConnections bool `json:"allowInsecureConnections,omitempty"`
}
type DeployerProvider struct {
@@ -38,6 +41,9 @@ func NewDeployer(config *DeployerConfig) (*DeployerProvider, error) {
SetTimeout(30 * time.Second).
SetRetryCount(3).
SetRetryWaitTime(5 * time.Second)
if config.AllowInsecureConnections {
client.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
}
return &DeployerProvider{
config: config,

View File

@@ -49,8 +49,9 @@ func TestDeploy(t *testing.T) {
}, "\n"))
deployer, err := provider.NewDeployer(&provider.DeployerConfig{
WebhookUrl: fWebhookUrl,
WebhookData: fWebhookData,
WebhookUrl: fWebhookUrl,
WebhookData: fWebhookData,
AllowInsecureConnections: true,
})
if err != nil {
t.Errorf("err: %+v", err)