Skip to content

Commit

Permalink
Merge pull request #464 from LiZhenCheng9527/fix-scp-license
Browse files Browse the repository at this point in the history
Replaced go-scp package
  • Loading branch information
kurator-bot authored Nov 23, 2023
2 parents 97ad334 + 5d1a37f commit a43b0c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ require (
github.com/agiledragon/gomonkey/v2 v2.10.1
github.com/aws/aws-sdk-go v1.44.191
github.com/awslabs/goformation/v4 v4.19.5
github.com/bramvdbogaerde/go-scp v1.2.0
github.com/cert-manager/cert-manager v1.10.0
github.com/coreos/go-semver v0.3.0
github.com/fluxcd/helm-controller/api v0.32.2
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,6 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dR
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/bramvdbogaerde/go-scp v1.2.0 h1:mNF1lCXQ6jQcxCBBuc2g/CQwVy/4QONaoD5Aqg9r+Zg=
github.com/bramvdbogaerde/go-scp v1.2.0/go.mod h1:s4ZldBoRAOgUg8IrRP2Urmq5qqd2yPXQTPshACY8vQ0=
github.com/brancz/gojsontoyaml v0.0.0-20190425155809-e8bd32d46b3d/go.mod h1:IyUJYN1gvWjtLF5ZuygmxbnsAyP3aJS6cHzIuZY50B0=
github.com/briankassouf/jose v0.9.2-0.20180619214549-d2569464773f/go.mod h1:HQhVmdUf7dBNwIIdBTivnCDxcf6IZY3/zrb+uKSJz6Y=
github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk=
Expand Down Expand Up @@ -2181,7 +2179,6 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
Expand Down Expand Up @@ -2483,7 +2480,6 @@ golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
25 changes: 17 additions & 8 deletions pkg/plugin/join/kubeedge/kubeedge.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ package kubeedge
import (
"context"
"fmt"
"io"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/bramvdbogaerde/go-scp"
"github.com/pkg/sftp"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -189,12 +190,9 @@ func (p *JoinPlugin) scpKeadm(sshClient *ssh.Client) error {
return nil
}

client, err := scp.NewClientBySSH(sshClient)
client, err := sftp.NewClient(sshClient)
if err != nil {
return fmt.Errorf("creating new SSH session from existing connection fail, %w", err)
}
if err := client.Connect(); err != nil {
return fmt.Errorf("establish a connection to the remote server fail, %w", err)
return fmt.Errorf("creating new SFTP session from existing connection failed: %w", err)
}
defer client.Close()

Expand All @@ -204,9 +202,20 @@ func (p *JoinPlugin) scpKeadm(sshClient *ssh.Client) error {
}
defer f.Close()

if err := client.CopyFromFile(context.Background(), *f, destPath, "0755"); err != nil {
return fmt.Errorf("scp file fail, %w", err)
dstFile, err := client.Create(destPath)
if err != nil {
return fmt.Errorf("failed to create remote file: %w", err)
}
defer dstFile.Close()

if _, err := io.Copy(dstFile, f); err != nil {
return fmt.Errorf("failed to copy file to remote server: %w", err)
}

if err := dstFile.Chmod(0755); err != nil {
return fmt.Errorf("failed to change file permissions on remote server: %w", err)
}

return nil
}

Expand Down

0 comments on commit a43b0c8

Please sign in to comment.