Skip to content

Commit

Permalink
1.add http deployment method
Browse files Browse the repository at this point in the history
Signed-off-by: liuminjian <liuminjian@chinatelecom.cn>
  • Loading branch information
liuminjian committed Dec 13, 2023
1 parent 28372fe commit d51ef71
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 11 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ GO := go

# output
OUTPUT := bin/curveadm
SERVER_OUTPUT := bin/pigeon

# build flags
LDFLAGS := -s -w
Expand Down Expand Up @@ -53,7 +52,6 @@ TEST_FLAGS += -run $(CASE)

# packages
PACKAGES := $(PWD)/cmd/curveadm/main.go
SERVER_PACKAGES := $(PWD)/cmd/service/main.go

# tar
VERSION := "unknown"
Expand Down
2 changes: 1 addition & 1 deletion cli/command/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func addSubCommands(cmd *cobra.Command, curveadm *cli.CurveAdm) {
target.NewTargetCommand(curveadm), // curveadm target ...
pfs.NewPFSCommand(curveadm), // curveadm pfs ...
monitor.NewMonitorCommand(curveadm), // curveadm monitor ...
daemon.NewDaemonCommand(curveadm), // curveadm http
daemon.NewDaemonCommand(curveadm), // curveadm deamon ...

NewAuditCommand(curveadm), // curveadm audit
NewCleanCommand(curveadm), // curveadm clean
Expand Down
6 changes: 3 additions & 3 deletions cli/command/daemon/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

/*
* Project: Curveadm
* Created Date: 2023-03-31
* Author: wanghai (SeanHai)
* Created Date: 2023-12-13
* Author: liuminjian
*/

package daemon
Expand All @@ -31,7 +31,7 @@ import (
func NewDaemonCommand(curveadm *cli.CurveAdm) *cobra.Command {
cmd := &cobra.Command{
Use: "daemon",
Short: "Manage http service",
Short: "Manage curveadm deamon service",
Args: cliutil.NoArgs,
RunE: cliutil.ShowHelp(curveadm.Err()),
}
Expand Down
1 change: 1 addition & 0 deletions internal/configure/hosts/hc_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (hc *HostConfig) GetConnectConfig() *module.ConnectConfig {
BecomeUser: hc.GetBecomeUser(),
ConnectTimeoutSec: curveadm.GlobalCurveAdmConfig.GetSSHTimeout(),
ConnectRetries: curveadm.GlobalCurveAdmConfig.GetSSHRetries(),
Protocol: hc.GetProtocol(),
}
}

Expand Down
3 changes: 2 additions & 1 deletion internal/configure/hosts/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/opencurve/curveadm/internal/configure/os"
"github.com/opencurve/curveadm/internal/errno"
"github.com/opencurve/curveadm/internal/utils"
"github.com/opencurve/curveadm/pkg/module"
"github.com/spf13/viper"
)

Expand Down Expand Up @@ -158,7 +159,7 @@ func (hc *HostConfig) Build() error {
F("hosts[%d].private_key_file = %s", hc.sequence, privateKeyFile)
}

if hc.GetForwardAgent() == false {
if hc.GetForwardAgent() == false && hc.GetProtocol() == module.SSH_PROTOCOL {
if !utils.PathExist(privateKeyFile) {
return errno.ERR_PRIVATE_KEY_FILE_NOT_EXIST.
F("%s: no such file", privateKeyFile)
Expand Down
3 changes: 2 additions & 1 deletion internal/task/task/checker/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/opencurve/curveadm/internal/task/step"
"github.com/opencurve/curveadm/internal/task/task"
"github.com/opencurve/curveadm/internal/utils"
"github.com/opencurve/curveadm/pkg/module"
)

const (
Expand All @@ -51,7 +52,7 @@ func doNothing() step.LambdaType {
func checkHost(hc *hosts.HostConfig) step.LambdaType {
return func(ctx *context.Context) error {
privateKeyFile := hc.GetPrivateKeyFile()
if hc.GetForwardAgent() == false {
if hc.GetForwardAgent() == false && hc.GetProtocol() == module.SSH_PROTOCOL {
if !utils.PathExist(privateKeyFile) {
return errno.ERR_PRIVATE_KEY_FILE_NOT_EXIST.
F("%s: no such file", privateKeyFile)
Expand Down
4 changes: 4 additions & 0 deletions pkg/module/remote_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ type RemoteClient interface {
}

func NewRemoteClient(cfg *ConnectConfig) (client RemoteClient, err error) {
if cfg == nil {
return
}

if cfg.Protocol == SSH_PROTOCOL {
client, err = NewSSHClient(*cfg.GetSSHConfig())
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ backup() {
}

setup() {
mkdir -p "${g_curveadm_home}"/{bin,data,module,logs,conf,temp}

mkdir -p "${g_curveadm_home}"/{bin,data,module,logs,temp}
mkdir -p "${g_curveadm_home}"/daemon/{logs,conf}
# generate config file
local confpath="${g_curveadm_home}/curveadm.cfg"
if [ ! -f "${confpath}" ]; then
Expand All @@ -70,7 +70,7 @@ __EOF__


# generate http service config file
local httpConfpath="${g_curveadm_home}/conf/pigeon.yaml"
local httpConfpath="${g_curveadm_home}/daemon/conf/pigeon.yaml"
if [ ! -f $httpConfpath ]; then
cat << __EOF__ > $httpConfpath
servers:
Expand Down

0 comments on commit d51ef71

Please sign in to comment.