Skip to content

Commit 0a6c8c2

Browse files
committed
fix(v1.0): support 实时输出
1 parent 1a78e7e commit 0a6c8c2

7 files changed

Lines changed: 9 additions & 151 deletions

File tree

cmd/root.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ var rootCmd = &cobra.Command{
6060

6161
func exec(ssh *sshutil.SSH, mode, host string) {
6262
switch mode {
63-
case "ssh":
64-
ssh.Cmd(host, command)
6563
case "scp":
6664
ssh.CopyForMD5(host, localFilePath, remoteFilePath, "")
67-
case "sshAsync":
65+
case "ssh":
6866
_ = ssh.CmdAsync(host, command)
6967
}
7068
}
@@ -113,6 +111,7 @@ func Execute() {
113111
}
114112

115113
func init() {
114+
logger.Cfg()
116115
// Here you will define your flags and configuration settings.
117116
rootCmd.Flags().StringVar(&user, "user", "root", "servers user name for ssh")
118117
rootCmd.Flags().StringVar(&password, "passwd", "", "password for ssh")
@@ -121,5 +120,5 @@ func init() {
121120
rootCmd.Flags().StringVar(&command, "cmd", "", "exec shell")
122121
rootCmd.Flags().StringVar(&localFilePath, "local-path", "", "local path , ex /etc/local.txt")
123122
rootCmd.Flags().StringVar(&remoteFilePath, "remote-path", "", "local path , ex /etc/local.txt")
124-
rootCmd.Flags().StringVar(&mode, "mode", "ssh", "mode type ,use | spilt . ex ssh sshAsync scp ssh|scp scp|ssh")
123+
rootCmd.Flags().StringVar(&mode, "mode", "ssh", "mode type ,use | spilt . ex ssh scp ssh|scp scp|ssh")
125124
}

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ require (
99
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586
1010
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae // indirect
1111
)
12+
13+
replace github.com/wonderivan/logger => github.com/fanux/sealos/pkg/logger v0.0.0-20200406033522-73f3ef41977c

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc
77
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
88
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
99
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
10+
github.com/fanux/sealos/pkg/logger v0.0.0-20200406033522-73f3ef41977c h1:oegX8xgoZ4xCXK7o2D8tLQd4uyQ8EVhsozRKOc+z5bI=
11+
github.com/fanux/sealos/pkg/logger v0.0.0-20200406033522-73f3ef41977c/go.mod h1:x9AaKiPmaa1lNJIu5XXJs1En2wZayGN6UA3dgYozYFk=
1012
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
1113
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
1214
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
@@ -37,8 +39,6 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
3739
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
3840
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
3941
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
40-
github.com/wonderivan/logger v1.0.0 h1:Z6Nz+3SNcizolx3ARH11axdD4DXjFpb2J+ziGUVlv/U=
41-
github.com/wonderivan/logger v1.0.0/go.mod h1:NObMfQ3WOLKfYEZuGeZQfuQfSPE5+QNgRddVMzsAT/k=
4242
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
4343
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
4444
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

pkg/cmd/watch.go

Lines changed: 0 additions & 58 deletions
This file was deleted.

pkg/filesize/filesize.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

pkg/sshutil/scp.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"time"
1313
)
1414

15+
const oneMBByte = 1024 * 1024
16+
1517
//Copy is
1618
func (ss *SSH) CopyForMD5(host, localFilePath, remoteFilePath, md5 string) bool {
1719
//如果有md5则可以验证

pkg/sshutil/watch.go

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)