Merge lp:~axwalk/juju-core/sshstorage-put-stdin into lp:~go-bot/juju-core/trunk
Proposed by
Andrew Wilkins
Status: | Merged |
---|---|
Approved by: | Andrew Wilkins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1865 |
Proposed branch: | lp:~axwalk/juju-core/sshstorage-put-stdin |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
88 lines (+28/-9) 2 files modified
environs/sshstorage/storage.go (+21/-9) environs/sshstorage/storage_test.go (+7/-0) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/sshstorage-put-stdin |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email:
|
Commit message
environs/
Write file contents via stdin, rather than
as a here document on the command line. This
enables writing of large files (e.g. juju
tools archives).
Description of the change
environs/
Write file contents via stdin, rather than
as a here document on the command line. This
enables writing of large files (e.g. juju
tools archives).
To post a comment you must log in.
Reviewers: mp+186936_ code.launchpad. net,
Message:
Please take a look.
Description: sshstorage: fix Put of large files
environs/
Write file contents via stdin, rather than
as a here document on the command line. This
enables writing of large files (e.g. juju
tools archives).
https:/ /code.launchpad .net/~axwalk/ juju-core/ sshstorage- put-stdin/ +merge/ 186936
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/13507045/
Affected files (+25, -9 lines): sshstorage/ storage. go sshstorage/ storage_ test.go
A [revision details]
M environs/
M environs/
Index: [revision details] 20130920052504- qqe61zp28ipkvyh 6
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: environs/ sshstorage/ storage. go sshstorage/ storage. go' sshstorage/ storage. go 2013-09-20 03:46:57 +0000 sshstorage/ storage. go 2013-09-22 13:32:02 +0000
=== modified file 'environs/
--- environs/
+++ environs/
@@ -123,21 +123,30 @@
func (s *SSHStorage) runf(flockmode flockmode, command string, command, args...)
args ...interface{}) (string, error) {
command = fmt.Sprintf(
- return s.run(flockmode, command)
+ return s.run(flockmode, command, nil)
}
-func (s *SSHStorage) run(flockmode flockmode, command string) (string, ShQuote( command) , Write([ ]byte(command + "\r\n")); err != nil { Write([ ]byte(command + "\n")); err != nil { StdEncoding. EncodeToString( input) Write([ ]byte(encoded + "\n")); err != nil { StdEncoding. EncodeToString( buf)
error) {
+func (s *SSHStorage) run(flockmode flockmode, command string, input
[]byte) (string, error) {
const rcPrefix = "JUJU-RC: "
command = fmt.Sprintf(
- "(SHELL=/bin/bash flock %s %s -c %s) 2>&1; echo %s$?",
+ "SHELL=/bin/bash flock %s %s -c %s",
flockmode,
s.remotepath,
utils.
- rcPrefix,
)
- if _, err := s.stdin.
+ if input != nil {
+ command = fmt.Sprintf("line | base64 -d | (%s)", command)
+ }
+ command = fmt.Sprintf("(%s) 2>&1; echo %s$?", command, rcPrefix)
+ if _, err := s.stdin.
return "", fmt.Errorf("failed to write command: %v", err)
}
+ if input != nil {
+ encoded := base64.
+ if _, err := s.stdin.
+ return "", fmt.Errorf("failed to write input: %v", err)
+ }
+ }
var output []string
for s.scanner.Scan() {
line := s.scanner.Text()
@@ -243,7 +252,6 @@
if _, err := r.Read(buf); err != nil {
return err
}
- encoded := base64.
path = utils.ShQuote(path)
tmpdir := s.tmpdir tmpdir)
@@ -253,7 +261,7 @@
tmpdir = utils.ShQuote(
// Write to a temporary file ($TMPFILE), then mv atomically.
- command := fmt.Sprintf("mkdir -p `dirname %s` && base64 -d > $TMPFILE",
path)
+ command := fmt.Sprintf("mkdir -p `dirname %s` && cat > $TMPFILE", path)
command = fmt.Sprintf(
"export TMPDIR=%s && TMPFILE=`mktemp` && ((%s && mv $TMPFILE %s) || rm
-f $TMPFILE)",
tmpdir, command, path,
@@ -269,8 +277,7 @@
command = fmt.Sprintf("%s && (%s); rc=$?; %s; exit $rc", installTmpdir,
command, removeTmpdir)
}
- command = fmt.Sprintf("(%s...