mirror of
https://github.com/usual2970/certimate.git
synced 2025-08-20 16:21:45 +00:00
feat: implement more Deployer
This commit is contained in:
@@ -18,10 +18,10 @@ import (
|
||||
|
||||
type SshDeployerConfig struct {
|
||||
// SSH 主机。
|
||||
// 空值时默认为 "localhost"。
|
||||
// 零值时默认为 "localhost"。
|
||||
SshHost string `json:"sshHost,omitempty"`
|
||||
// SSH 端口。
|
||||
// 空值时默认为 22。
|
||||
// 零值时默认为 22。
|
||||
SshPort int32 `json:"sshPort,omitempty"`
|
||||
// SSH 登录用户名。
|
||||
SshUsername string `json:"sshUsername,omitempty"`
|
||||
@@ -36,7 +36,6 @@ type SshDeployerConfig struct {
|
||||
// 后置命令。
|
||||
PostCommand string `json:"postCommand,omitempty"`
|
||||
// 输出证书格式。
|
||||
// 空值时默认为 [OUTPUT_FORMAT_PEM]。
|
||||
OutputFormat OutputFormatType `json:"outputFormat,omitempty"`
|
||||
// 输出证书文件路径。
|
||||
OutputCertPath string `json:"outputCertPath,omitempty"`
|
||||
@@ -61,6 +60,8 @@ type SshDeployer struct {
|
||||
logger deployer.Logger
|
||||
}
|
||||
|
||||
var _ deployer.Deployer = (*SshDeployer)(nil)
|
||||
|
||||
func New(config *SshDeployerConfig) (*SshDeployer, error) {
|
||||
return NewWithLogger(config, deployer.NewNilLogger())
|
||||
}
|
||||
@@ -109,7 +110,7 @@ func (d *SshDeployer) Deploy(ctx context.Context, certPem string, privkeyPem str
|
||||
|
||||
// 上传证书和私钥文件
|
||||
switch d.config.OutputFormat {
|
||||
case "", OUTPUT_FORMAT_PEM:
|
||||
case OUTPUT_FORMAT_PEM:
|
||||
if err := writeSftpFileString(client, d.config.OutputCertPath, certPem); err != nil {
|
||||
return nil, xerrors.Wrap(err, "failed to upload certificate file")
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
dSsh "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/ssh"
|
||||
dpSsh "github.com/usual2970/certimate/internal/pkg/core/deployer/providers/ssh"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -64,7 +64,7 @@ func Test(t *testing.T) {
|
||||
fmt.Sprintf("OUTPUTKEYPATH: %v", fOutputKeyPath),
|
||||
}, "\n"))
|
||||
|
||||
deployer, err := dSsh.New(&dSsh.SshDeployerConfig{
|
||||
deployer, err := dpSsh.New(&dpSsh.SshDeployerConfig{
|
||||
SshHost: fSshHost,
|
||||
SshPort: int32(fSshPort),
|
||||
SshUsername: fSshUsername,
|
||||
|
Reference in New Issue
Block a user