Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmidt75 committed Mar 5, 2021
1 parent 24c7ba8 commit 3026a2a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
48 changes: 24 additions & 24 deletions integration/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (ipvsconfig *IPVSConfig) Apply(newconfig *IPVSConfig, opts ApplyOpts) error
// create changeset from new configuration
cs, err := ipvsconfig.ChangeSet(newconfig, opts)
if err != nil {
return &IPVSApplyError{ what: "Unable to build change set from new configuration", origErr: err}
return &IPVSApplyError{what: "Unable to build change set from new configuration", origErr: err}
}

log.WithField("changeset", cs).Debug("Applying changeset")
Expand All @@ -36,7 +36,7 @@ func (ipvsconfig *IPVSConfig) Apply(newconfig *IPVSConfig, opts ApplyOpts) error
}

// ApplyChangeSet takes a chhange set and applies all change items to
// the given IPVSConfig
// the given IPVSConfig
func (ipvsconfig *IPVSConfig) ApplyChangeSet(newconfig *IPVSConfig, cs *ChangeSet, opts ApplyOpts) error {

ipvs, err := ipvs.New("")
Expand All @@ -51,64 +51,64 @@ func (ipvsconfig *IPVSConfig) ApplyChangeSet(newconfig *IPVSConfig, cs *ChangeSe
for idx, csiIntf := range cs.Items {
csi := csiIntf.(ChangeSetItem)
log.WithFields(log.Fields{
"idx": idx,
"idx": idx,
"csi": csi,
}).Tracef("Checking change set item")

switch csi.Type {
case DeleteService:
allowed, found := allowedActions[ApplyActionDeleteService]
if !found || ! allowed {
if !found || !allowed {
return &IPVSApplyError{what: "not allowed to delete a service"}
}
case AddService:
allowed, found := allowedActions[ApplyActionAddService]
if !found || ! allowed {
if !found || !allowed {
return &IPVSApplyError{what: "not allowed to add a service"}
}
// if service has destinations, check as well if allowed
if len(csi.Service.Destinations) > 0 {
allowed, found = allowedActions[ApplyActionAddDestination]
if !found || ! allowed {
if !found || !allowed {
return &IPVSApplyError{what: "not allowed to add a destinations"}
}
}
case UpdateService:
allowed, found := allowedActions[ApplyActionUpdateService]
if !found || ! allowed {
if !found || !allowed {
return &IPVSApplyError{what: "not allowed to update a service"}
}
case AddDestination:
allowed, found := allowedActions[ApplyActionAddDestination]
if !found || ! allowed {
if !found || !allowed {
return &IPVSApplyError{what: "not allowed to add a destination"}
}
case DeleteDestination:
allowed, found := allowedActions[ApplyActionDeleteDestination]
if !found || ! allowed {
if !found || !allowed {
return &IPVSApplyError{what: "not allowed to delete a destination"}
}
case UpdateDestination:
allowed, found := allowedActions[ApplyActionUpdateDestination]
if !found || ! allowed {
if !found || !allowed {
return &IPVSApplyError{what: "not allowed to update a destination"}
}
default:
log.WithField("type", csi.Type).Tracef("Unhandled change type")
log.WithField("type", csi.Type).Tracef("Unhandled change type")
}
}

for idx, csiIntf := range cs.Items {
csi := csiIntf.(ChangeSetItem)
log.WithFields(log.Fields{
"idx": idx,
"idx": idx,
"csi": csi,
}).Tracef("Applying change set item")

switch csi.Type {
case DeleteService:
log.WithFields(log.Fields{
"addr": csi.Service.Address,
"addr": csi.Service.Address,
"sched": csi.Service.SchedName,
}).Tracef("Removing service from current config")

Expand All @@ -118,7 +118,7 @@ func (ipvsconfig *IPVSConfig) ApplyChangeSet(newconfig *IPVSConfig, cs *ChangeSe
}
case AddService:
log.WithFields(log.Fields{
"addr": csi.Service.Address,
"addr": csi.Service.Address,
"sched": csi.Service.SchedName,
}).Tracef("Adding to current config")

Expand All @@ -135,7 +135,7 @@ func (ipvsconfig *IPVSConfig) ApplyChangeSet(newconfig *IPVSConfig, cs *ChangeSe
}

log.WithFields(log.Fields{
"ipvssvc": newIPVSService,
"ipvssvc": newIPVSService,
}).Tracef("added")

newIPVSDestinations, err := newconfig.NewIpvsDestinationsStruct(csi.Service)
Expand All @@ -151,7 +151,7 @@ func (ipvsconfig *IPVSConfig) ApplyChangeSet(newconfig *IPVSConfig, cs *ChangeSe
}
case UpdateService:
log.WithFields(log.Fields{
"addr": csi.Service.Address,
"addr": csi.Service.Address,
}).Tracef("Updating service")

newIPVSService, err := newconfig.NewIpvsServiceStruct(csi.Service)
Expand All @@ -164,11 +164,11 @@ func (ipvsconfig *IPVSConfig) ApplyChangeSet(newconfig *IPVSConfig, cs *ChangeSe
return &IPVSApplyError{what: "unable to edit ipvs service", origErr: err}
}
log.Tracef("edited service: %#v\n", newIPVSService)

case AddDestination:
log.WithFields(log.Fields{
"dst-addr": csi.Destination.Address,
"dst": csi.Destination,
"dst-addr": csi.Destination.Address,
"dst": csi.Destination,
"svc-addr": csi.Service.Address,
}).Tracef("Adding destination to current config")

Expand All @@ -183,8 +183,8 @@ func (ipvsconfig *IPVSConfig) ApplyChangeSet(newconfig *IPVSConfig, cs *ChangeSe

case DeleteDestination:
log.WithFields(log.Fields{
"dst-addr": csi.Destination.Address,
"dst": csi.Destination,
"dst-addr": csi.Destination.Address,
"dst": csi.Destination,
"svc-addr": csi.Service.Address,
}).Tracef("Removing destination from current config")

Expand All @@ -195,8 +195,8 @@ func (ipvsconfig *IPVSConfig) ApplyChangeSet(newconfig *IPVSConfig, cs *ChangeSe

case UpdateDestination:
log.WithFields(log.Fields{
"dst-addr": csi.Destination.Address,
"dst": csi.Destination,
"dst-addr": csi.Destination.Address,
"dst": csi.Destination,
"svc-addr": csi.Service.Address,
}).Tracef("Updating destination")

Expand All @@ -211,7 +211,7 @@ func (ipvsconfig *IPVSConfig) ApplyChangeSet(newconfig *IPVSConfig, cs *ChangeSe
}

default:
log.WithField("type", csi.Type).Tracef("Unhandled change type")
log.WithField("type", csi.Type).Tracef("Unhandled change type")
}
}

Expand Down
4 changes: 2 additions & 2 deletions integration/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func getDestinationsForService(ipvs *ipvs.Handle, service *ipvs.Service, s *Serv

for idx, dest := range dests {
log.WithFields(log.Fields{
"idx": idx,
"idx": idx,
"dest": *dest,
}).Trace("processing")

Expand All @@ -103,7 +103,7 @@ func getDestinationsForService(ipvs *ipvs.Handle, service *ipvs.Service, s *Serv
// MakeAdressStringFromIpvsService creates a model-valid address
// string from an ipvs.Service entry.
func MakeAdressStringFromIpvsService(service *ipvs.Service) string {
var adrStr = ""
var adrStr string
if service.Protocol != 0 {
protoStr := protoNumToStr(service)
ipStr := fmt.Sprintf("%s", service.Address)
Expand Down
2 changes: 1 addition & 1 deletion integration/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func splitHostPort(in string) (host string, port int, err error) {
return a[0], int(p), nil
}

func splitCompoundAddress(in string) (procotol, addressPart string, port, fwmark int, err error) {
func splitCompoundAddress(in string) (protocol, addressPart string, port, fwmark int, err error) {
if strings.HasPrefix(in, "fwmark:") {
// treat rest as fwmark integer
a := strings.Split(in, ":")
Expand Down
6 changes: 3 additions & 3 deletions integration/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestSplitProtoHostPort(t *testing.T) {
for _, table := range tables {
p, hp, err := splitProtoHostPort(table.in)
if err != nil {
t.Errorf("Internal error occured: %s", err)
t.Errorf("Internal error occurred: %s", err)
}
if p != table.proto {
t.Errorf("Proto was incorrect: %s", p)
Expand All @@ -43,7 +43,7 @@ func TestSplitHostPort(t *testing.T) {
for _, table := range tables {
h, p, err := splitHostPort(table.in)
if err != nil {
t.Errorf("Internal error occured: %s", err)
t.Errorf("Internal error occurred: %s", err)
}
if p != table.port {
t.Errorf("port was incorrect: %d", p)
Expand All @@ -67,7 +67,7 @@ func TestSplitCompoundAddress(t *testing.T) {
for _, table := range tables {
p, ap, port, fwmark, err := splitCompoundAddress(table.in)
if err != nil {
t.Errorf("Internal error occured: %s", err)
t.Errorf("Internal error occurred: %s", err)
}
if p != table.p {
t.Errorf("Proto was incorrect: %s", p)
Expand Down
4 changes: 2 additions & 2 deletions ipvs/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// from libnetwork: https://github.com/docker/libnetwork
// Code and documentation copyright 2015 Docker, inc.
// Code released under the Apache 2.0 license.
// Code and documentation copyright 2015 Docker, inc.
// Code released under the Apache 2.0 license.
// +build linux

package ipvs
Expand Down
4 changes: 2 additions & 2 deletions ipvs/ipvs_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// from libnetwork: https://github.com/docker/libnetwork
// Code and documentation copyright 2015 Docker, inc.
// Code released under the Apache 2.0 license.
// Code and documentation copyright 2015 Docker, inc.
// Code released under the Apache 2.0 license.
// +build linux

package ipvs
Expand Down

0 comments on commit 3026a2a

Please sign in to comment.