Skip to content

Commit

Permalink
chore(deps): bump golangci-lint from v1.51.2 to v1.53.3 (#7334)
Browse files Browse the repository at this point in the history
Signed-off-by: Charly Molter <charly.molter@konghq.com>
  • Loading branch information
lahabana authored and kumahq[bot] committed Sep 25, 2023
1 parent b50dcdc commit 2d45c45
Show file tree
Hide file tree
Showing 41 changed files with 3,403 additions and 24 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Golangci-lint
on:
push:
pull_request:
permissions:
contents: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
cache: false
go-version: 1.20.5
- uses: golangci/golangci-lint-action@v3
with:
args: --verbose
version: v1.53.3
2 changes: 1 addition & 1 deletion app/kumactl/cmd/get/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var _ = Describe("kumactl get ", func() {
It("should have get commands for all defined types", func() {
// when
all := registry.Global().ObjectDescriptors(model.HasKumactlEnabled())
Expect(len(getCmd.Commands()) > len(all)).To(BeTrue())
Expect(len(getCmd.Commands())).To(BeNumerically(">", len(all)))

// then
for _, sub := range all {
Expand Down
4 changes: 4 additions & 0 deletions mk/dependencies/deps.lock
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<<<<<<< HEAD
7845b9a40ddd58573a26d21df57fc4973febe633
=======
ddcb18fef158bd55f6534f1a4ab75af4f9db3b6f
>>>>>>> 409438fbc (chore(deps): bump golangci-lint from v1.51.2 to v1.53.3 (#7334))
8 changes: 8 additions & 0 deletions mk/dev.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ ifdef XDG_DATA_HOME
endif
CI_TOOLS_BIN_DIR=$(CI_TOOLS_DIR)/bin

<<<<<<< HEAD
=======
# Change here and `make check` ensures these are used for CI
K8S_MIN_VERSION = v1.22.9-k3s1
K8S_MAX_VERSION = v1.27.1-k3s1
export GO_VERSION=1.20.5
export GOLANGCI_LINT_VERSION=v1.53.3
>>>>>>> 409438fbc (chore(deps): bump golangci-lint from v1.51.2 to v1.53.3 (#7334))
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)

Expand Down
2 changes: 1 addition & 1 deletion pkg/core/logs/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ var _ = Describe("Matcher", func() {

// then
Expect(err).ToNot(HaveOccurred())
Expect(log).To(HaveLen(0))
Expect(log).To(BeEmpty())
})

It("should skip unknown backends", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var _ = Describe("DataplaneInsight Manager", func() {
Expect(err).ToNot(HaveOccurred())

// then
Expect(actual.Spec.Subscriptions).To(HaveLen(0))
Expect(actual.Spec.Subscriptions).To(BeEmpty())
Expect(actual.Spec.Subscriptions).To(BeNil())
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = Describe("ZoneEgressInsight Manager", func() {
Expect(err).ToNot(HaveOccurred())

// then
Expect(actual.Spec.Subscriptions).To(HaveLen(0))
Expect(actual.Spec.Subscriptions).To(BeEmpty())
Expect(actual.Spec.Subscriptions).To(BeNil())
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = Describe("ZoneIngressInsight Manager", func() {
Expect(err).ToNot(HaveOccurred())

// then
Expect(actual.Spec.Subscriptions).To(HaveLen(0))
Expect(actual.Spec.Subscriptions).To(BeEmpty())
Expect(actual.Spec.Subscriptions).To(BeNil())
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = Describe("ZoneInsight Manager", func() {
Expect(err).ToNot(HaveOccurred())

// then
Expect(actual.Spec.Subscriptions).To(HaveLen(0))
Expect(actual.Spec.Subscriptions).To(BeEmpty())
Expect(actual.Spec.Subscriptions).To(BeNil())
})
})
204 changes: 204 additions & 0 deletions pkg/intercp/catalog/catalog_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
package catalog_test

import (
"context"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/kumahq/kuma/pkg/core/resources/manager"
"github.com/kumahq/kuma/pkg/intercp/catalog"
"github.com/kumahq/kuma/pkg/plugins/resources/memory"
)

var _ = Describe("Catalog", func() {
var c catalog.Catalog

BeforeEach(func() {
store := memory.NewStore()
resManager := manager.NewResourceManager(store)
c = catalog.NewConfigCatalog(resManager)
})

Context("Replace", func() {
instances := []catalog.Instance{
{
Id: "instance-1",
Leader: true,
},
}

BeforeEach(func() {
_, err := c.Replace(context.Background(), instances)
Expect(err).ToNot(HaveOccurred())
})

It("should replace existing instances", func() {
// when
instances := []catalog.Instance{
{
Id: "instance-1",
Leader: false,
},
{
Id: "instance-2",
Leader: true,
},
}
updated, err := c.Replace(context.Background(), instances)

// then
Expect(updated).To(BeTrue())
Expect(err).ToNot(HaveOccurred())

readInstances, err := c.Instances(context.Background())
Expect(readInstances).To(Equal(instances))
Expect(err).ToNot(HaveOccurred())
})

It("should return false if replace did not replace instances", func() {
// when
updated, err := c.Replace(context.Background(), instances)

// then
Expect(updated).To(BeFalse())
Expect(err).ToNot(HaveOccurred())
})
})

Context("ReplaceLeader", func() {
leader := catalog.Instance{
Id: "leader-1",
Leader: true,
}

It("should replace leader when catalog is empty", func() {
// when
err := c.ReplaceLeader(context.Background(), leader)

// then
Expect(err).ToNot(HaveOccurred())

readInstances, err := c.Instances(context.Background())
Expect(err).ToNot(HaveOccurred())
Expect(readInstances).To(HaveLen(1))
Expect(readInstances[0]).To(Equal(leader))
})

It("should replace leader when there is another leader", func() {
// given
instances := []catalog.Instance{
{
Id: "instance-1",
Leader: true,
},
{
Id: "leader-1",
Leader: false,
},
}
_, err := c.Replace(context.Background(), instances)
Expect(err).ToNot(HaveOccurred())

// when
err = c.ReplaceLeader(context.Background(), leader)

// then
Expect(err).ToNot(HaveOccurred())

readInstances, err := c.Instances(context.Background())
Expect(err).ToNot(HaveOccurred())
Expect(readInstances).To(HaveLen(2))
Expect(readInstances[0].Id).To(Equal("instance-1"))
Expect(readInstances[0].Leader).To(BeFalse())
Expect(readInstances[1].Id).To(Equal("leader-1"))
Expect(readInstances[1].Leader).To(BeTrue())
})

It("should replace leader when the new leader is not on the list", func() {
// given
instances := []catalog.Instance{
{
Id: "instance-1",
Leader: true,
},
}
_, err := c.Replace(context.Background(), instances)
Expect(err).ToNot(HaveOccurred())

// when
err = c.ReplaceLeader(context.Background(), leader)

// then
Expect(err).ToNot(HaveOccurred())

readInstances, err := c.Instances(context.Background())
Expect(err).ToNot(HaveOccurred())
Expect(readInstances).To(HaveLen(2))
Expect(readInstances[0].Id).To(Equal("instance-1"))
Expect(readInstances[0].Leader).To(BeFalse())
Expect(readInstances[1].Id).To(Equal("leader-1"))
Expect(readInstances[1].Leader).To(BeTrue())
})
})

Context("Leader", func() {
It("should return a leader if there is a leader in the list", func() {
// given
instances := []catalog.Instance{
{
Id: "instance-1",
Leader: false,
},
{
Id: "instance-2",
Leader: true,
},
}
_, err := c.Replace(context.Background(), instances)
Expect(err).ToNot(HaveOccurred())

// when
leader, err := catalog.Leader(context.Background(), c)

// then
Expect(err).ToNot(HaveOccurred())
Expect(leader.Id).To(Equal("instance-2"))
})

It("should return an error if there is no leader", func() {
// given
instances := []catalog.Instance{
{
Id: "instance-1",
Leader: false,
},
}
_, err := c.Replace(context.Background(), instances)
Expect(err).ToNot(HaveOccurred())

// when
_, err = catalog.Leader(context.Background(), c)

// then
Expect(err).To(Equal(catalog.ErrNoLeader))
})
})

It("should return empty instances if the catalog was never updated", func() {
// when
instances, err := c.Instances(context.Background())

// then
Expect(err).ToNot(HaveOccurred())
Expect(instances).To(BeEmpty())
})

It("should handle IPV6 addresses when building inter cp URL", func() {
instance := catalog.Instance{
Address: "2001:0db8:85a3:0000",
InterCpPort: 5683,
}
Expect(instance.InterCpURL()).To(Equal("grpcs://[2001:0db8:85a3:0000]:5683"))
})
})
25 changes: 22 additions & 3 deletions pkg/kds/server/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,30 @@ import (
util_xds_v3 "github.com/kumahq/kuma/pkg/util/xds/v3"
)

<<<<<<< HEAD
func New(log logr.Logger, rt core_runtime.Runtime, providedTypes []model.ResourceType, serverID string, refresh time.Duration, filter reconcile.ResourceFilter, mapper reconcile.ResourceMapper, insight bool) (Server, error) {
hasher, cache := newKDSContext(log)
=======
func New(
log logr.Logger,
rt core_runtime.Runtime,
providedTypes []model.ResourceType,
serverID string,
refresh time.Duration,
filter reconcile.ResourceFilter,
mapper reconcile.ResourceMapper,
insight bool,
nackBackoff time.Duration,
) (Server, error) {
hashFn, cache := newKDSContext(log)
>>>>>>> 409438fbc (chore(deps): bump golangci-lint from v1.51.2 to v1.53.3 (#7334))
generator := reconcile.NewSnapshotGenerator(rt.ReadOnlyResourceManager(), providedTypes, filter, mapper)
versioner := util_xds_v3.SnapshotAutoVersioner{UUID: core.NewUUID}
statsCallbacks, err := util_xds.NewStatsCallbacks(rt.Metrics(), "kds")
if err != nil {
return nil, err
}
reconciler := reconcile.NewReconciler(hasher, cache, generator, versioner, rt.Config().Mode, statsCallbacks)
reconciler := reconcile.NewReconciler(hashFn, cache, generator, versioner, rt.Config().Mode, statsCallbacks)
syncTracker, err := newSyncTracker(log, reconciler, refresh, rt.Metrics())
if err != nil {
return nil, err
Expand Down Expand Up @@ -103,9 +118,10 @@ func newSyncTracker(log logr.Logger, reconciler reconcile.Reconciler, refresh ti
}), nil
}

func newKDSContext(log logr.Logger) (envoy_cache.NodeHash, util_xds_v3.SnapshotCache) {
hasher := hasher{}
func newKDSContext(log logr.Logger) (envoy_cache.NodeHash, util_xds_v3.SnapshotCache) { //nolint:unparam
hashFn := util_xds_v3.IDHash{}
logger := util_xds.NewLogger(log)
<<<<<<< HEAD
return hasher, util_xds_v3.NewSnapshotCache(false, hasher, logger)
}

Expand All @@ -114,4 +130,7 @@ type hasher struct {

func (_ hasher) ID(node *envoy_core.Node) string {
return node.Id
=======
return hashFn, util_xds_v3.NewSnapshotCache(false, hashFn, logger)
>>>>>>> 409438fbc (chore(deps): bump golangci-lint from v1.51.2 to v1.53.3 (#7334))
}
Loading

0 comments on commit 2d45c45

Please sign in to comment.