Skip to content

Commit

Permalink
Rename egress-cidrs to egress-subnets
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed Aug 30, 2017
1 parent 792de65 commit 895a44b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions apiserver/common/firewall/egressaddresswatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (w *EgressAddressWatcher) initialise() error {
if err != nil {
return err
}
w.knownEgress = set.NewStrings(cfg.EgressCidrs()...)
w.knownEgress = set.NewStrings(cfg.EgressSubnets()...)
return nil
}

Expand Down Expand Up @@ -184,7 +184,7 @@ func (w *EgressAddressWatcher) loop() error {
if err != nil {
return err
}
egress := set.NewStrings(cfg.EgressCidrs()...)
egress := set.NewStrings(cfg.EgressSubnets()...)
// Have the egress addresses changed.
if egress.Size() != w.knownEgress.Size() ||
egress.Difference(w.knownEgress).Size() != 0 || w.knownEgress.Difference(egress).Size() != 0 {
Expand Down
6 changes: 3 additions & 3 deletions apiserver/common/firewall/egressaddresswatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func (s *addressWatcherSuite) TestHandlesUnitGoneWhenMachineAddressChanges(c *gc
}

func (s *addressWatcherSuite) TestEgressAddressConfigured(c *gc.C) {
s.st.configAttrs["egress-cidrs"] = "10.0.0.1/16"
s.st.configAttrs["egress-subnets"] = "10.0.0.1/16"
rel := s.setupRelation(c, "54.1.2.3")
w, err := firewall.NewEgressAddressWatcher(s.st, rel, "django")
c.Assert(err, jc.ErrorIsNil)
Expand All @@ -421,13 +421,13 @@ func (s *addressWatcherSuite) TestEgressAddressConfigured(c *gc.C) {
wc.AssertNoChange()

// Change user configured egress addresses.
s.st.configAttrs["egress-cidrs"] = "192.168.0.1/16"
s.st.configAttrs["egress-subnets"] = "192.168.0.1/16"
s.st.modelWatcher.changes <- struct{}{}
wc.AssertChange("192.168.0.1/16")
wc.AssertNoChange()

// Reset user configured egress addresses.
s.st.configAttrs["egress-cidrs"] = ""
s.st.configAttrs["egress-subnets"] = ""
s.st.modelWatcher.changes <- struct{}{}
wc.AssertChange("54.1.2.3/32")
wc.AssertNoChange()
Expand Down
18 changes: 9 additions & 9 deletions environs/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ const (
// UpdateStatusHookInterval is how often to run the update-status hook.
UpdateStatusHookInterval = "update-status-hook-interval"

// EgressCidrs are the source addresses from which traffic from this model
// EgressSubnets are the source addresses from which traffic from this model
// originates if the model is deployed such that NAT or similar is in use.
EgressCidrs = "egress-cidrs"
EgressSubnets = "egress-subnets"

//
// Deprecated Settings Attributes
Expand Down Expand Up @@ -367,7 +367,7 @@ var defaultConfigValues = map[string]interface{}{
"test-mode": false,
TransmitVendorMetricsKey: true,
UpdateStatusHookInterval: DefaultUpdateStatusHookInterval,
EgressCidrs: "",
EgressSubnets: "",

// Image and agent streams and URLs.
"image-stream": "released",
Expand Down Expand Up @@ -549,7 +549,7 @@ func Validate(cfg, old *Config) error {
}
}

if v, ok := cfg.defined[EgressCidrs].(string); ok && v != "" {
if v, ok := cfg.defined[EgressSubnets].(string); ok && v != "" {
addresses := strings.Split(v, ",")
for _, addr := range addresses {
if _, _, err := net.ParseCIDR(strings.TrimSpace(addr)); err != nil {
Expand Down Expand Up @@ -1023,10 +1023,10 @@ func (c *Config) UpdateStatusHookInterval() time.Duration {
return val
}

// EgressCidrs are the source addresses from which traffic from this model
// EgressSubnets are the source addresses from which traffic from this model
// originates if the model is deployed such that NAT or similar is in use.
func (c *Config) EgressCidrs() []string {
raw := c.asString(EgressCidrs)
func (c *Config) EgressSubnets() []string {
raw := c.asString(EgressSubnets)
if raw == "" {
return []string{}
}
Expand Down Expand Up @@ -1149,7 +1149,7 @@ var alwaysOptional = schema.Defaults{
MaxActionResultsAge: schema.Omit,
MaxActionResultsSize: schema.Omit,
UpdateStatusHookInterval: schema.Omit,
EgressCidrs: schema.Omit,
EgressSubnets: schema.Omit,
}

func allowEmpty(attr string) bool {
Expand Down Expand Up @@ -1546,7 +1546,7 @@ data of the store. (default false)`,
Type: environschema.Tstring,
Group: environschema.EnvironGroup,
},
EgressCidrs: {
EgressSubnets: {
Description: "Source address(es) for traffic originating from this model",
Type: environschema.Tstring,
Group: environschema.EnvironGroup,
Expand Down
6 changes: 3 additions & 3 deletions environs/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1124,11 +1124,11 @@ func (s *ConfigSuite) TestUpdateStatusHookIntervalConfigValue(c *gc.C) {
c.Assert(cfg.UpdateStatusHookInterval(), gc.Equals, 30*time.Minute)
}

func (s *ConfigSuite) TestEgressCidrs(c *gc.C) {
func (s *ConfigSuite) TestEgressSubnets(c *gc.C) {
cfg := newTestConfig(c, testing.Attrs{
"egress-cidrs": "10.0.0.1/32, 192.168.1.1/16",
"egress-subnets": "10.0.0.1/32, 192.168.1.1/16",
})
c.Assert(cfg.EgressCidrs(), gc.DeepEquals, []string{"10.0.0.1/32", "192.168.1.1/16"})
c.Assert(cfg.EgressSubnets(), gc.DeepEquals, []string{"10.0.0.1/32", "192.168.1.1/16"})
}

func (s *ConfigSuite) TestSchemaNoExtra(c *gc.C) {
Expand Down
2 changes: 1 addition & 1 deletion state/relationunit.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func (ru *RelationUnit) IngressAddress() (network.Address, error) {
if err != nil {
return network.Address{}, errors.Trace(err)
}
cidrs := cfg.EgressCidrs()
cidrs := cfg.EgressSubnets()
if len(cidrs) > 0 {
ip, _, err := net.ParseCIDR(cidrs[0])
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions state/relationunit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,8 @@ func (s *RelationUnitSuite) TestIngressAddressRemoteRelationNoPublicAddr(c *gc.C
c.Assert(address, gc.DeepEquals, network.NewScopedAddress("1.2.3.4", network.ScopeCloudLocal))
}

func (s *RelationUnitSuite) TestIngressAddressRemoteRelationEgressCidrs(c *gc.C) {
err := s.State.UpdateModelConfig(map[string]interface{}{"egress-cidrs": "192.168.1.0/32"}, nil)
func (s *RelationUnitSuite) TestIngressAddressRemoteRelationEgressSubnets(c *gc.C) {
err := s.State.UpdateModelConfig(map[string]interface{}{"egress-subnets": "192.168.1.0/32"}, nil)
c.Assert(err, jc.ErrorIsNil)
prr := newRemoteProReqRelation(c, &s.ConnSuite)
err = prr.ru0.AssignToNewMachine()
Expand Down

0 comments on commit 895a44b

Please sign in to comment.