Merge lp:~thumper/juju-core/proxy-values-exported-in-cloudinit into lp:~go-bot/juju-core/trunk

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2261
Proposed branch: lp:~thumper/juju-core/proxy-values-exported-in-cloudinit
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 36 lines (+9/-3)
2 files modified
environs/cloudinit/cloudinit.go (+2/-0)
environs/cloudinit/cloudinit_test.go (+7/-3)
To merge this branch: bzr merge lp:~thumper/juju-core/proxy-values-exported-in-cloudinit
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+203269@code.launchpad.net

Commit message

Export the proxy settings in cloud-init

The tools are downloaded using wget, and wget
supports proxies. So best pass the proxy information
to the environment so wget can use it.

https://codereview.appspot.com/57130043/

Description of the change

Export the proxy settings in cloud-init

The tools are downloaded using wget, and wget
supports proxies. So best pass the proxy informatino
to the environment so wget can use it.

https://codereview.appspot.com/57130043/

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Reviewers: mp+203269_code.launchpad.net,

Message:
Please take a look.

Description:
Export the proxy settings in cloud-init

The tools are downloaded using wget, and wget
supports proxies. So best pass the proxy informatino
to the environment so wget can use it.

https://code.launchpad.net/~thumper/juju-core/proxy-values-exported-in-cloudinit/+merge/203269

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/57130043/

Affected files (+11, -3 lines):
   A [revision details]
   M environs/cloudinit/cloudinit.go
   M environs/cloudinit/cloudinit_test.go

Index: [revision details]
=== 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-20140125125332-eckpnh62bygibitl
+New revision: <email address hidden>

Index: environs/cloudinit/cloudinit.go
=== modified file 'environs/cloudinit/cloudinit.go'
--- environs/cloudinit/cloudinit.go 2014-01-24 01:05:52 +0000
+++ environs/cloudinit/cloudinit.go 2014-01-26 23:28:43 +0000
@@ -268,6 +268,8 @@
    `([ ! -e /home/ubuntu/.profile ] || grep -q '.juju-proxy'
/home/ubuntu/.profile) || ` +
     `printf '\n# Added by juju\n[ -f "$HOME/.juju-proxy" ]
&& . "$HOME/.juju-proxy"\n' >> /home/ubuntu/.profile`)
   if (cfg.ProxySettings != osenv.ProxySettings{}) {
+ exportedProxyEnv := cfg.ProxySettings.AsScriptEnvironment()
+ c.AddScripts(strings.Split(exportedProxyEnv, "\n")...)
    c.AddScripts(
     fmt.Sprintf(
      `[ -e /home/ubuntu ] && (printf '%%s\n' %s > /home/ubuntu/.juju-proxy
&& chown ubuntu:ubuntu /home/ubuntu/.juju-proxy)`,

Index: environs/cloudinit/cloudinit_test.go
=== modified file 'environs/cloudinit/cloudinit_test.go'
--- environs/cloudinit/cloudinit_test.go 2014-01-23 22:10:46 +0000
+++ environs/cloudinit/cloudinit_test.go 2014-01-26 23:28:43 +0000
@@ -848,12 +848,16 @@

   cmds := cloudcfg.RunCmds()
   first := `([ ! -e /home/ubuntu/.profile ] || grep -q '.juju-proxy'
/home/ubuntu/.profile) || printf '\n# Added by juju\n[
-f "$HOME/.juju-proxy" ] && . "$HOME/.juju-proxy"\n' >>
/home/ubuntu/.profile`
- second := `[ -e /home/ubuntu ] && (printf '%s\n' 'export
http_proxy=http://user@10.0.0.1
-export HTTP_PROXY=http://user@10.0.0.1' > /home/ubuntu/.juju-proxy &&
chown ubuntu:ubuntu /home/ubuntu/.juju-proxy)`
+ expected := []interface{}{
+ `export http_proxy=http://user@10.0.0.1`,
+ `export HTTP_PROXY=http://user@10.0.0.1`,
+ `[ -e /home/ubuntu ] && (printf '%s\n' 'export
http_proxy=http://user@10.0.0.1
+export HTTP_PROXY=http://user@10.0.0.1' > /home/ubuntu/.juju-proxy &&
chown ubuntu:ubuntu /home/ubuntu/.juju-proxy)`,
+ }
   found := false
   for i, cmd := range cmds {
    if cmd == first {
- c.Assert(cmds[i+1], gc.Equals, second)
+ c.Assert(cmds[i+1:i+4], jc.DeepEquals, expected)
     found = true
     break
    }

Revision history for this message
Dimiter Naydenov (dimitern) wrote :

LGTM, just a minor typo in the description: s/informatino/information/.

https://codereview.appspot.com/57130043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/cloudinit/cloudinit.go'
2--- environs/cloudinit/cloudinit.go 2014-01-24 01:05:52 +0000
3+++ environs/cloudinit/cloudinit.go 2014-01-26 23:33:39 +0000
4@@ -268,6 +268,8 @@
5 `([ ! -e /home/ubuntu/.profile ] || grep -q '.juju-proxy' /home/ubuntu/.profile) || ` +
6 `printf '\n# Added by juju\n[ -f "$HOME/.juju-proxy" ] && . "$HOME/.juju-proxy"\n' >> /home/ubuntu/.profile`)
7 if (cfg.ProxySettings != osenv.ProxySettings{}) {
8+ exportedProxyEnv := cfg.ProxySettings.AsScriptEnvironment()
9+ c.AddScripts(strings.Split(exportedProxyEnv, "\n")...)
10 c.AddScripts(
11 fmt.Sprintf(
12 `[ -e /home/ubuntu ] && (printf '%%s\n' %s > /home/ubuntu/.juju-proxy && chown ubuntu:ubuntu /home/ubuntu/.juju-proxy)`,
13
14=== modified file 'environs/cloudinit/cloudinit_test.go'
15--- environs/cloudinit/cloudinit_test.go 2014-01-23 22:10:46 +0000
16+++ environs/cloudinit/cloudinit_test.go 2014-01-26 23:33:39 +0000
17@@ -848,12 +848,16 @@
18
19 cmds := cloudcfg.RunCmds()
20 first := `([ ! -e /home/ubuntu/.profile ] || grep -q '.juju-proxy' /home/ubuntu/.profile) || printf '\n# Added by juju\n[ -f "$HOME/.juju-proxy" ] && . "$HOME/.juju-proxy"\n' >> /home/ubuntu/.profile`
21- second := `[ -e /home/ubuntu ] && (printf '%s\n' 'export http_proxy=http://user@10.0.0.1
22-export HTTP_PROXY=http://user@10.0.0.1' > /home/ubuntu/.juju-proxy && chown ubuntu:ubuntu /home/ubuntu/.juju-proxy)`
23+ expected := []interface{}{
24+ `export http_proxy=http://user@10.0.0.1`,
25+ `export HTTP_PROXY=http://user@10.0.0.1`,
26+ `[ -e /home/ubuntu ] && (printf '%s\n' 'export http_proxy=http://user@10.0.0.1
27+export HTTP_PROXY=http://user@10.0.0.1' > /home/ubuntu/.juju-proxy && chown ubuntu:ubuntu /home/ubuntu/.juju-proxy)`,
28+ }
29 found := false
30 for i, cmd := range cmds {
31 if cmd == first {
32- c.Assert(cmds[i+1], gc.Equals, second)
33+ c.Assert(cmds[i+1:i+4], jc.DeepEquals, expected)
34 found = true
35 break
36 }

Subscribers

People subscribed via source and target branches

to status/vote changes: