feat: add cdnfly deployer

This commit is contained in:
Fu Diwei
2025-02-18 15:14:24 +08:00
parent 46f02331fd
commit 03d2f4ca32
122 changed files with 955 additions and 243 deletions

View File

@@ -3,6 +3,7 @@
import (
"context"
"errors"
"net/url"
xerrors "github.com/pkg/errors"
@@ -34,11 +35,11 @@ func New(config *BaotaPanelConsoleDeployerConfig) (*BaotaPanelConsoleDeployer, e
func NewWithLogger(config *BaotaPanelConsoleDeployerConfig, logger logger.Logger) (*BaotaPanelConsoleDeployer, error) {
if config == nil {
return nil, errors.New("config is nil")
panic("config is nil")
}
if logger == nil {
return nil, errors.New("logger is nil")
panic("logger is nil")
}
client, err := createSdkClient(config.ApiUrl, config.ApiKey)
@@ -82,6 +83,14 @@ func (d *BaotaPanelConsoleDeployer) Deploy(ctx context.Context, certPem string,
}
func createSdkClient(apiUrl, apiKey string) (*btsdk.Client, error) {
if _, err := url.Parse(apiUrl); err != nil {
return nil, errors.New("invalid baota api url")
}
if apiKey == "" {
return nil, errors.New("invalid baota api key")
}
client := btsdk.NewClient(apiUrl, apiKey)
return client, nil
}

View File

@@ -33,8 +33,8 @@ Shell command to run this test:
go test -v ./baotapanel_console_test.go -args \
--CERTIMATE_DEPLOYER_BAOTAPANELCONSOLE_INPUTCERTPATH="/path/to/your-input-cert.pem" \
--CERTIMATE_DEPLOYER_BAOTAPANELCONSOLE_INPUTKEYPATH="/path/to/your-input-key.pem" \
--CERTIMATE_DEPLOYER_BAOTAPANELCONSOLE_APIURL="your-baota-panel-url" \
--CERTIMATE_DEPLOYER_BAOTAPANELCONSOLE_APIKEY="your-baota-panel-key"
--CERTIMATE_DEPLOYER_BAOTAPANELCONSOLE_APIURL="http://127.0.0.1:8888" \
--CERTIMATE_DEPLOYER_BAOTAPANELCONSOLE_APIKEY="your-api-key"
*/
func TestDeploy(t *testing.T) {
flag.Parse()