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
32b9a305
Commit
32b9a305
authored
Oct 09, 2013
by
Rafael Garcia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provisioner/salt-masterless: use communicator.UploadDir
parent
ff970483
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
52 deletions
+4
-52
provisioner/salt-masterless/provisioner.go
provisioner/salt-masterless/provisioner.go
+4
-52
No files found.
provisioner/salt-masterless/provisioner.go
View file @
32b9a305
...
...
@@ -8,8 +8,6 @@ import (
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer"
"os"
"path/filepath"
"strings"
)
const
DefaultTempConfigDir
=
"/tmp/salt"
...
...
@@ -146,7 +144,8 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
}
ui
.
Message
(
fmt
.
Sprintf
(
"Uploading local state tree: %s"
,
p
.
config
.
LocalStateTree
))
if
err
=
UploadLocalDirectory
(
p
.
config
.
LocalStateTree
,
fmt
.
Sprintf
(
"%s/states"
,
p
.
config
.
TempConfigDir
),
comm
,
ui
);
err
!=
nil
{
if
err
=
comm
.
UploadDir
(
fmt
.
Sprintf
(
"%s/states"
,
p
.
config
.
TempConfigDir
),
p
.
config
.
LocalStateTree
,
[]
string
{
".git"
});
err
!=
nil
{
return
fmt
.
Errorf
(
"Error uploading local state tree to remote: %s"
,
err
)
}
...
...
@@ -161,18 +160,9 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
}
if
p
.
config
.
LocalPillarRoots
!=
""
{
ui
.
Message
(
fmt
.
Sprintf
(
"Creating remote pillar directory: %s/pillar"
,
p
.
config
.
TempConfigDir
))
cmd
:=
&
packer
.
RemoteCmd
{
Command
:
fmt
.
Sprintf
(
"mkdir -p %s/pillar"
,
p
.
config
.
TempConfigDir
)}
if
err
=
cmd
.
StartWithUi
(
comm
,
ui
);
err
!=
nil
||
cmd
.
ExitStatus
!=
0
{
if
err
==
nil
{
err
=
fmt
.
Errorf
(
"Bad exit status: %d"
,
cmd
.
ExitStatus
)
}
return
fmt
.
Errorf
(
"Error creating remote pillar directory: %s"
,
err
)
}
ui
.
Message
(
fmt
.
Sprintf
(
"Uploading local pillar roots: %s"
,
p
.
config
.
LocalPillarRoots
))
if
err
=
UploadLocalDirectory
(
p
.
config
.
LocalPillarRoots
,
fmt
.
Sprintf
(
"%s/pillar"
,
p
.
config
.
TempConfigDir
),
comm
,
ui
);
err
!=
nil
{
if
err
=
comm
.
UploadDir
(
fmt
.
Sprintf
(
"%s/pillar"
,
p
.
config
.
TempConfigDir
),
p
.
config
.
LocalPillarRoots
,
[]
string
{
".git"
});
err
!=
nil
{
return
fmt
.
Errorf
(
"Error uploading local pillar roots to remote: %s"
,
err
)
}
...
...
@@ -206,44 +196,6 @@ func (p *Provisioner) Cancel() {
os
.
Exit
(
0
)
}
func
UploadLocalDirectory
(
localDir
string
,
remoteDir
string
,
comm
packer
.
Communicator
,
ui
packer
.
Ui
)
(
err
error
)
{
visitPath
:=
func
(
localPath
string
,
f
os
.
FileInfo
,
err
error
)
(
err2
error
)
{
localRelPath
:=
strings
.
Replace
(
localPath
,
localDir
,
""
,
1
)
localRelPath
=
strings
.
Replace
(
localRelPath
,
"
\\
"
,
"/"
,
-
1
)
remotePath
:=
filepath
.
Join
(
remoteDir
,
localRelPath
)
if
f
.
IsDir
()
&&
f
.
Name
()
==
".git"
{
return
filepath
.
SkipDir
}
if
f
.
IsDir
()
{
// Make remote directory
cmd
:=
&
packer
.
RemoteCmd
{
Command
:
fmt
.
Sprintf
(
"mkdir -p %s"
,
remotePath
)}
if
err
=
cmd
.
StartWithUi
(
comm
,
ui
);
err
!=
nil
{
return
err
}
}
else
{
// Upload file to existing directory
file
,
err
:=
os
.
Open
(
localPath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error opening file: %s"
,
err
)
}
defer
file
.
Close
()
ui
.
Message
(
fmt
.
Sprintf
(
"Uploading file %s: %s"
,
localPath
,
remotePath
))
if
err
=
comm
.
Upload
(
remotePath
,
file
);
err
!=
nil
{
return
fmt
.
Errorf
(
"Error uploading file: %s"
,
err
)
}
}
return
}
err
=
filepath
.
Walk
(
localDir
,
visitPath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error uploading local directory %s: %s"
,
localDir
,
err
)
}
return
nil
}
func
uploadMinionConfig
(
comm
packer
.
Communicator
,
dst
string
,
src
string
)
error
{
f
,
err
:=
os
.
Open
(
src
)
if
err
!=
nil
{
...
...
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