Merge lp:~thumper/juju-core/config-proxy 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: 2224
Proposed branch: lp:~thumper/juju-core/config-proxy
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 135 lines (+100/-0)
2 files modified
environs/config/config.go (+53/-0)
environs/config/config_test.go (+47/-0)
To merge this branch: bzr merge lp:~thumper/juju-core/config-proxy
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+202371@code.launchpad.net

Commit message

Add generic proxy settings to the config.

Add proxy settings for http, https and ftp. Also separate
out the apt-*-proxy settings from the others as you may
want apt to go through a different location.

https://codereview.appspot.com/54680043/

Description of the change

Add generic proxy settings to the config.

Add proxy settings for http, https and ftp. Also separate
out the apt-*-proxy settings from the others as you may
want apt to go through a different location.

https://codereview.appspot.com/54680043/

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

Reviewers: mp+202371_code.launchpad.net,

Message:
Please take a look.

Description:
Add generic proxy settings to the config.

Add proxy settings for http, https and ftp. Also separate
out the apt-*-proxy settings from the others as you may
want apt to go through a different location.

https://code.launchpad.net/~thumper/juju-core/config-proxy/+merge/202371

(do not edit description out of merge proposal)

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

Affected files (+102, -0 lines):
   A [revision details]
   M environs/config/config.go
   M environs/config/config_test.go

Revision history for this message
Andrew Wilkins (axwalk) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/config/config.go'
2--- environs/config/config.go 2014-01-10 10:18:43 +0000
3+++ environs/config/config.go 2014-01-20 20:37:10 +0000
4@@ -406,6 +406,47 @@
5 return c.mustString("authorized-keys")
6 }
7
8+// HttpProxy returns the http proxy for the environment.
9+func (c *Config) HttpProxy() string {
10+ return c.asString("http-proxy")
11+}
12+
13+// HttpsProxy returns the https proxy for the environment.
14+func (c *Config) HttpsProxy() string {
15+ return c.asString("https-proxy")
16+}
17+
18+// FtpProxy returns the ftp proxy for the environment.
19+func (c *Config) FtpProxy() string {
20+ return c.asString("ftp-proxy")
21+}
22+
23+func (c *Config) getWithFallback(key, fallback string) string {
24+ value := c.asString(key)
25+ if value == "" {
26+ value = c.asString(fallback)
27+ }
28+ return value
29+}
30+
31+// AptHttpProxy returns the apt http proxy for the environment.
32+// Falls back to the default http-proxy if not specified.
33+func (c *Config) AptHttpProxy() string {
34+ return c.getWithFallback("apt-http-proxy", "http-proxy")
35+}
36+
37+// AptHttpsProxy returns the apt https proxy for the environment.
38+// Falls back to the default https-proxy if not specified.
39+func (c *Config) AptHttpsProxy() string {
40+ return c.getWithFallback("apt-https-proxy", "https-proxy")
41+}
42+
43+// AptFtpProxy returns the apt ftp proxy for the environment.
44+// Falls back to the default ftp-proxy if not specified.
45+func (c *Config) AptFtpProxy() string {
46+ return c.getWithFallback("apt-ftp-proxy", "ftp-proxy")
47+}
48+
49 // CACert returns the certificate of the CA that signed the state server
50 // certificate, in PEM format, and whether the setting is available.
51 func (c *Config) CACert() ([]byte, bool) {
52@@ -554,6 +595,12 @@
53 "logging-config": schema.String(),
54 "charm-store-auth": schema.String(),
55 "provisioner-safe-mode": schema.Bool(),
56+ "http-proxy": schema.String(),
57+ "https-proxy": schema.String(),
58+ "ftp-proxy": schema.String(),
59+ "apt-http-proxy": schema.String(),
60+ "apt-https-proxy": schema.String(),
61+ "apt-ftp-proxy": schema.String(),
62
63 // Deprecated fields, retain for backwards compatibility.
64 "tools-url": schema.String(),
65@@ -576,6 +623,12 @@
66 "ca-private-key-path": schema.Omit,
67 "logging-config": schema.Omit,
68 "provisioner-safe-mode": schema.Omit,
69+ "http-proxy": schema.Omit,
70+ "https-proxy": schema.Omit,
71+ "ftp-proxy": schema.Omit,
72+ "apt-http-proxy": schema.Omit,
73+ "apt-https-proxy": schema.Omit,
74+ "apt-ftp-proxy": schema.Omit,
75
76 // Deprecated fields, retain for backwards compatibility.
77 "tools-url": "",
78
79=== modified file 'environs/config/config_test.go'
80--- environs/config/config_test.go 2013-12-19 00:38:03 +0000
81+++ environs/config/config_test.go 2014-01-20 20:37:10 +0000
82@@ -1088,6 +1088,53 @@
83 c.Assert(config.LoggingConfig(), gc.Equals, logConfig)
84 }
85
86+func (*ConfigSuite) TestProxyValuesWithFallback(c *gc.C) {
87+ defer makeFakeHome(c).Restore()
88+
89+ config := newTestConfig(c, testing.Attrs{
90+ "http-proxy": "http://user@10.0.0.1",
91+ "https-proxy": "https://user@10.0.0.1",
92+ "ftp-proxy": "ftp://user@10.0.0.1",
93+ })
94+ c.Assert(config.HttpProxy(), gc.Equals, "http://user@10.0.0.1")
95+ c.Assert(config.AptHttpProxy(), gc.Equals, "http://user@10.0.0.1")
96+ c.Assert(config.HttpsProxy(), gc.Equals, "https://user@10.0.0.1")
97+ c.Assert(config.AptHttpsProxy(), gc.Equals, "https://user@10.0.0.1")
98+ c.Assert(config.FtpProxy(), gc.Equals, "ftp://user@10.0.0.1")
99+ c.Assert(config.AptFtpProxy(), gc.Equals, "ftp://user@10.0.0.1")
100+}
101+
102+func (*ConfigSuite) TestProxyValues(c *gc.C) {
103+ defer makeFakeHome(c).Restore()
104+
105+ config := newTestConfig(c, testing.Attrs{
106+ "http-proxy": "http://user@10.0.0.1",
107+ "https-proxy": "https://user@10.0.0.1",
108+ "ftp-proxy": "ftp://user@10.0.0.1",
109+ "apt-http-proxy": "http://user@10.0.0.2",
110+ "apt-https-proxy": "https://user@10.0.0.2",
111+ "apt-ftp-proxy": "ftp://user@10.0.0.2",
112+ })
113+ c.Assert(config.HttpProxy(), gc.Equals, "http://user@10.0.0.1")
114+ c.Assert(config.AptHttpProxy(), gc.Equals, "http://user@10.0.0.2")
115+ c.Assert(config.HttpsProxy(), gc.Equals, "https://user@10.0.0.1")
116+ c.Assert(config.AptHttpsProxy(), gc.Equals, "https://user@10.0.0.2")
117+ c.Assert(config.FtpProxy(), gc.Equals, "ftp://user@10.0.0.1")
118+ c.Assert(config.AptFtpProxy(), gc.Equals, "ftp://user@10.0.0.2")
119+}
120+
121+func (*ConfigSuite) TestProxyValuesNotSet(c *gc.C) {
122+ defer makeFakeHome(c).Restore()
123+
124+ config := newTestConfig(c, testing.Attrs{})
125+ c.Assert(config.HttpProxy(), gc.Equals, "")
126+ c.Assert(config.AptHttpProxy(), gc.Equals, "")
127+ c.Assert(config.HttpsProxy(), gc.Equals, "")
128+ c.Assert(config.AptHttpsProxy(), gc.Equals, "")
129+ c.Assert(config.FtpProxy(), gc.Equals, "")
130+ c.Assert(config.AptFtpProxy(), gc.Equals, "")
131+}
132+
133 func (*ConfigSuite) TestGenerateStateServerCertAndKey(c *gc.C) {
134 // In order to test missing certs, it checks the JUJU_HOME dir, so we need
135 // a fake home.

Subscribers

People subscribed via source and target branches

to status/vote changes: