Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
1010c8ae
Commit
1010c8ae
authored
Aug 23, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/rpc: implement UploadDir
parent
8b21b5b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
2 deletions
+54
-2
packer/communicator_mock.go
packer/communicator_mock.go
+9
-1
packer/rpc/communicator.go
packer/rpc/communicator.go
+23
-1
packer/rpc/communicator_test.go
packer/rpc/communicator_test.go
+22
-0
No files found.
packer/communicator_mock.go
View file @
1010c8ae
...
...
@@ -20,6 +20,10 @@ type MockCommunicator struct {
UploadPath
string
UploadData
string
UploadDirDst
string
UploadDirSrc
string
UploadDirExclude
[]
string
DownloadCalled
bool
DownloadPath
string
DownloadData
string
...
...
@@ -78,7 +82,11 @@ func (c *MockCommunicator) Upload(path string, r io.Reader) error {
return
nil
}
func
(
c
*
MockCommunicator
)
UploadDir
(
string
,
string
,
[]
string
)
error
{
func
(
c
*
MockCommunicator
)
UploadDir
(
dst
string
,
src
string
,
excl
[]
string
)
error
{
c
.
UploadDirDst
=
dst
c
.
UploadDirSrc
=
src
c
.
UploadDirExclude
=
excl
return
nil
}
...
...
packer/rpc/communicator.go
View file @
1010c8ae
...
...
@@ -44,6 +44,12 @@ type CommunicatorUploadArgs struct {
ReaderAddress
string
}
type
CommunicatorUploadDirArgs
struct
{
Dst
string
Src
string
Exclude
[]
string
}
func
Communicator
(
client
*
rpc
.
Client
)
*
communicator
{
return
&
communicator
{
client
}
}
...
...
@@ -124,7 +130,19 @@ func (c *communicator) Upload(path string, r io.Reader) (err error) {
}
func
(
c
*
communicator
)
UploadDir
(
dst
string
,
src
string
,
exclude
[]
string
)
error
{
return
nil
args
:=
&
CommunicatorUploadDirArgs
{
Dst
:
dst
,
Src
:
src
,
Exclude
:
exclude
,
}
var
reply
error
err
:=
c
.
client
.
Call
(
"Communicator.UploadDir"
,
args
,
&
reply
)
if
err
==
nil
{
err
=
reply
}
return
err
}
func
(
c
*
communicator
)
Download
(
path
string
,
w
io
.
Writer
)
(
err
error
)
{
...
...
@@ -227,6 +245,10 @@ func (c *CommunicatorServer) Upload(args *CommunicatorUploadArgs, reply *interfa
return
}
func
(
c
*
CommunicatorServer
)
UploadDir
(
args
*
CommunicatorUploadDirArgs
,
reply
*
error
)
error
{
return
c
.
c
.
UploadDir
(
args
.
Dst
,
args
.
Src
,
args
.
Exclude
)
}
func
(
c
*
CommunicatorServer
)
Download
(
args
*
CommunicatorDownloadArgs
,
reply
*
interface
{})
(
err
error
)
{
writerC
,
err
:=
net
.
Dial
(
"tcp"
,
args
.
WriterAddress
)
if
err
!=
nil
{
...
...
packer/rpc/communicator_test.go
View file @
1010c8ae
...
...
@@ -5,6 +5,7 @@ import (
"github.com/mitchellh/packer/packer"
"io"
"net/rpc"
"reflect"
"testing"
)
...
...
@@ -104,6 +105,27 @@ func TestCommunicatorRPC(t *testing.T) {
t
.
Fatalf
(
"bad: %s"
,
c
.
UploadData
)
}
// Test that we can upload directories
dirDst
:=
"foo"
dirSrc
:=
"bar"
dirExcl
:=
[]
string
{
"foo"
}
err
=
remote
.
UploadDir
(
dirDst
,
dirSrc
,
dirExcl
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
c
.
UploadDirDst
!=
dirDst
{
t
.
Fatalf
(
"bad: %s"
,
c
.
UploadDirDst
)
}
if
c
.
UploadDirSrc
!=
dirSrc
{
t
.
Fatalf
(
"bad: %s"
,
c
.
UploadDirSrc
)
}
if
!
reflect
.
DeepEqual
(
c
.
UploadDirExclude
,
dirExcl
)
{
t
.
Fatalf
(
"bad: %#v"
,
c
.
UploadDirExclude
)
}
// Test that we can download things
downloadR
,
downloadW
:=
io
.
Pipe
()
downloadDone
:=
make
(
chan
bool
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment