Skip to content

Commit

Permalink
golangci-lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nyanpassu committed Sep 23, 2021
1 parent 7971879 commit 3983962
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
6 changes: 1 addition & 5 deletions cmd/ctr/ctr.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ import (
"github.com/projecteru2/barrel/versioninfo"
)

type Config struct {
}

func main() {
cli.VersionPrinter = func(c *cli.Context) {
fmt.Print(versioninfo.VersionString())
}

var app *cli.App
app = &cli.App{
app := &cli.App{
Name: "Barrel Ctr",
Version: versioninfo.VERSION,
Before: func(c *cli.Context) error {
Expand Down
17 changes: 8 additions & 9 deletions ctr/ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ func (c *Ctr) ListAffinityBlocks(ctx context.Context, hostname string, poolname
// Lookup blocks affine to the specified host.
opts := model.BlockAffinityListOptions{Host: hostname, IPVersion: 4}
datastoreObjs, err := c.backend.List(ctx, opts, "")
if err != nil {
if _, ok := err.(cerrors.ErrorResourceDoesNotExist); ok {
// The block path does not exist yet. This is OK - it means
// there are no affine blocks.
return result, nil
} else {
log.Errorf("Error getting affine blocks: %v", err)
return nil, err
}

if _, ok := err.(cerrors.ErrorResourceDoesNotExist); ok {
// The block path does not exist yet. This is OK - it means
// there are no affine blocks.
return result, nil
} else if err != nil {
log.Errorf("Error getting affine blocks: %v", err)
return nil, err
}

// Iterate through and extract the block CIDRs.
Expand Down
12 changes: 5 additions & 7 deletions ctr/wep.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ func (c *Ctr) RecycleWorkloadEndpoint(ctx context.Context, wep v3.WorkloadEndpoi
for _, ipCidr := range wep.Spec.IPNetworks {
if ip, _, err := net.ParseCIDR(ipCidr); err != nil {
log.WithError(err).Errorf("Parse cidr %s error, failed to recycle ip", ipCidr)
} else {
if err := c.UnassignIP(ctx, types.IP{
PoolID: opts.IPPoolName,
Address: ip.String(),
}); err != nil {
log.WithError(err).Errorf("Failed to recycle ip %s", ipCidr)
}
} else if err := c.UnassignIP(ctx, types.IP{
PoolID: opts.IPPoolName,
Address: ip.String(),
}); err != nil {
log.WithError(err).Errorf("Failed to recycle ip %s", ipCidr)
}
}
return nil
Expand Down

0 comments on commit 3983962

Please sign in to comment.