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
=== modified file 'environs/config/config.go'
--- environs/config/config.go 2014-01-10 10:18:43 +0000
+++ environs/config/config.go 2014-01-20 20:37:10 +0000
@@ -406,6 +406,47 @@
406 return c.mustString("authorized-keys")406 return c.mustString("authorized-keys")
407}407}
408408
409// HttpProxy returns the http proxy for the environment.
410func (c *Config) HttpProxy() string {
411 return c.asString("http-proxy")
412}
413
414// HttpsProxy returns the https proxy for the environment.
415func (c *Config) HttpsProxy() string {
416 return c.asString("https-proxy")
417}
418
419// FtpProxy returns the ftp proxy for the environment.
420func (c *Config) FtpProxy() string {
421 return c.asString("ftp-proxy")
422}
423
424func (c *Config) getWithFallback(key, fallback string) string {
425 value := c.asString(key)
426 if value == "" {
427 value = c.asString(fallback)
428 }
429 return value
430}
431
432// AptHttpProxy returns the apt http proxy for the environment.
433// Falls back to the default http-proxy if not specified.
434func (c *Config) AptHttpProxy() string {
435 return c.getWithFallback("apt-http-proxy", "http-proxy")
436}
437
438// AptHttpsProxy returns the apt https proxy for the environment.
439// Falls back to the default https-proxy if not specified.
440func (c *Config) AptHttpsProxy() string {
441 return c.getWithFallback("apt-https-proxy", "https-proxy")
442}
443
444// AptFtpProxy returns the apt ftp proxy for the environment.
445// Falls back to the default ftp-proxy if not specified.
446func (c *Config) AptFtpProxy() string {
447 return c.getWithFallback("apt-ftp-proxy", "ftp-proxy")
448}
449
409// CACert returns the certificate of the CA that signed the state server450// CACert returns the certificate of the CA that signed the state server
410// certificate, in PEM format, and whether the setting is available.451// certificate, in PEM format, and whether the setting is available.
411func (c *Config) CACert() ([]byte, bool) {452func (c *Config) CACert() ([]byte, bool) {
@@ -554,6 +595,12 @@
554 "logging-config": schema.String(),595 "logging-config": schema.String(),
555 "charm-store-auth": schema.String(),596 "charm-store-auth": schema.String(),
556 "provisioner-safe-mode": schema.Bool(),597 "provisioner-safe-mode": schema.Bool(),
598 "http-proxy": schema.String(),
599 "https-proxy": schema.String(),
600 "ftp-proxy": schema.String(),
601 "apt-http-proxy": schema.String(),
602 "apt-https-proxy": schema.String(),
603 "apt-ftp-proxy": schema.String(),
557604
558 // Deprecated fields, retain for backwards compatibility.605 // Deprecated fields, retain for backwards compatibility.
559 "tools-url": schema.String(),606 "tools-url": schema.String(),
@@ -576,6 +623,12 @@
576 "ca-private-key-path": schema.Omit,623 "ca-private-key-path": schema.Omit,
577 "logging-config": schema.Omit,624 "logging-config": schema.Omit,
578 "provisioner-safe-mode": schema.Omit,625 "provisioner-safe-mode": schema.Omit,
626 "http-proxy": schema.Omit,
627 "https-proxy": schema.Omit,
628 "ftp-proxy": schema.Omit,
629 "apt-http-proxy": schema.Omit,
630 "apt-https-proxy": schema.Omit,
631 "apt-ftp-proxy": schema.Omit,
579632
580 // Deprecated fields, retain for backwards compatibility.633 // Deprecated fields, retain for backwards compatibility.
581 "tools-url": "",634 "tools-url": "",
582635
=== modified file 'environs/config/config_test.go'
--- environs/config/config_test.go 2013-12-19 00:38:03 +0000
+++ environs/config/config_test.go 2014-01-20 20:37:10 +0000
@@ -1088,6 +1088,53 @@
1088 c.Assert(config.LoggingConfig(), gc.Equals, logConfig)1088 c.Assert(config.LoggingConfig(), gc.Equals, logConfig)
1089}1089}
10901090
1091func (*ConfigSuite) TestProxyValuesWithFallback(c *gc.C) {
1092 defer makeFakeHome(c).Restore()
1093
1094 config := newTestConfig(c, testing.Attrs{
1095 "http-proxy": "http://user@10.0.0.1",
1096 "https-proxy": "https://user@10.0.0.1",
1097 "ftp-proxy": "ftp://user@10.0.0.1",
1098 })
1099 c.Assert(config.HttpProxy(), gc.Equals, "http://user@10.0.0.1")
1100 c.Assert(config.AptHttpProxy(), gc.Equals, "http://user@10.0.0.1")
1101 c.Assert(config.HttpsProxy(), gc.Equals, "https://user@10.0.0.1")
1102 c.Assert(config.AptHttpsProxy(), gc.Equals, "https://user@10.0.0.1")
1103 c.Assert(config.FtpProxy(), gc.Equals, "ftp://user@10.0.0.1")
1104 c.Assert(config.AptFtpProxy(), gc.Equals, "ftp://user@10.0.0.1")
1105}
1106
1107func (*ConfigSuite) TestProxyValues(c *gc.C) {
1108 defer makeFakeHome(c).Restore()
1109
1110 config := newTestConfig(c, testing.Attrs{
1111 "http-proxy": "http://user@10.0.0.1",
1112 "https-proxy": "https://user@10.0.0.1",
1113 "ftp-proxy": "ftp://user@10.0.0.1",
1114 "apt-http-proxy": "http://user@10.0.0.2",
1115 "apt-https-proxy": "https://user@10.0.0.2",
1116 "apt-ftp-proxy": "ftp://user@10.0.0.2",
1117 })
1118 c.Assert(config.HttpProxy(), gc.Equals, "http://user@10.0.0.1")
1119 c.Assert(config.AptHttpProxy(), gc.Equals, "http://user@10.0.0.2")
1120 c.Assert(config.HttpsProxy(), gc.Equals, "https://user@10.0.0.1")
1121 c.Assert(config.AptHttpsProxy(), gc.Equals, "https://user@10.0.0.2")
1122 c.Assert(config.FtpProxy(), gc.Equals, "ftp://user@10.0.0.1")
1123 c.Assert(config.AptFtpProxy(), gc.Equals, "ftp://user@10.0.0.2")
1124}
1125
1126func (*ConfigSuite) TestProxyValuesNotSet(c *gc.C) {
1127 defer makeFakeHome(c).Restore()
1128
1129 config := newTestConfig(c, testing.Attrs{})
1130 c.Assert(config.HttpProxy(), gc.Equals, "")
1131 c.Assert(config.AptHttpProxy(), gc.Equals, "")
1132 c.Assert(config.HttpsProxy(), gc.Equals, "")
1133 c.Assert(config.AptHttpsProxy(), gc.Equals, "")
1134 c.Assert(config.FtpProxy(), gc.Equals, "")
1135 c.Assert(config.AptFtpProxy(), gc.Equals, "")
1136}
1137
1091func (*ConfigSuite) TestGenerateStateServerCertAndKey(c *gc.C) {1138func (*ConfigSuite) TestGenerateStateServerCertAndKey(c *gc.C) {
1092 // In order to test missing certs, it checks the JUJU_HOME dir, so we need1139 // In order to test missing certs, it checks the JUJU_HOME dir, so we need
1093 // a fake home.1140 // a fake home.

Subscribers

People subscribed via source and target branches

to status/vote changes: