Skip to content

Commit

Permalink
Updating go-lint version
Browse files Browse the repository at this point in the history
  • Loading branch information
vinaygonuguntla committed Aug 3, 2022
1 parent 2cf1147 commit 904cd9c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golang-ci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.43.0
version: v1.47.3
skip-go-installation: true

# Optional: working directory, useful for monorepos
Expand Down
6 changes: 2 additions & 4 deletions admiral/pkg/clusters/envoyfilter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package clusters

import (
"errors"
"fmt"
"github.com/gogo/protobuf/types"
v1 "github.com/istio-ecosystem/admiral/admiral/pkg/apis/admiral/v1"
Expand All @@ -11,7 +12,6 @@ import (
networking "istio.io/client-go/pkg/apis/networking/v1alpha3"
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strings"
"errors"
)

var (
Expand Down Expand Up @@ -177,9 +177,7 @@ func getHosts(routingPolicy *v1.RoutingPolicy) string {
for _, host := range routingPolicy.Spec.Hosts {
hosts += host + ","
}
if strings.HasSuffix(hosts, ",") {
hosts = hosts[:len(hosts)-len(",")]
}
hosts = strings.TrimSuffix(hosts,",")
return hostsKey + hosts
}

3 changes: 2 additions & 1 deletion admiral/pkg/clusters/envoyfilter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestCreateOrUpdateEnvoyFilter(t *testing.T) {
ClusterRegistriesNamespace: "default",
DependenciesNamespace: "default",
SecretResolver: "",
EnvoyFilterVersion: "1.13",
}

p.LabelSet.WorkloadIdentityKey = "identity"
Expand All @@ -51,7 +52,7 @@ func TestCreateOrUpdateEnvoyFilter(t *testing.T) {

remoteController.RoutingPolicyController = routingPolicyController

registry.RemoteControllers = map[string]*RemoteController{"cluster-1": remoteController}
registry.remoteControllers = map[string]*RemoteController{"cluster-1": remoteController}
registry.AdmiralCache.RoutingPolicyFilterCache = rpFilterCache

// foo is dependent upon bar and bar has a deployment in the same cluster.
Expand Down
2 changes: 2 additions & 0 deletions admiral/pkg/clusters/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func init() {
SecretResolver: "",
WorkloadSidecarUpdate: "enabled",
WorkloadSidecarName: "default",
EnableRoutingPolicy: true,
EnvoyFilterVersion: "1.13",
}

p.LabelSet.WorkloadIdentityKey = "identity"
Expand Down
2 changes: 2 additions & 0 deletions admiral/pkg/clusters/serviceentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ func TestCreateServiceEntryForNewServiceOrPodRolloutsUsecase(t *testing.T) {
GlobalTrafficCache: &globalTrafficCache{},
DependencyNamespaceCache: common.NewSidecarEgressMap(),
SeClusterCache: common.NewMapOfMaps(),
WorkloadSelectorCache: common.NewMapOfMaps(),
}
rr.AdmiralCache = admiralCache

Expand Down Expand Up @@ -1044,6 +1045,7 @@ func TestCreateServiceEntryForBlueGreenRolloutsUsecase(t *testing.T) {
GlobalTrafficCache: &globalTrafficCache{},
DependencyNamespaceCache: common.NewSidecarEgressMap(),
SeClusterCache: common.NewMapOfMaps(),
WorkloadSelectorCache: common.NewMapOfMaps(),
}
rr.AdmiralCache = admiralCache

Expand Down
23 changes: 18 additions & 5 deletions admiral/pkg/clusters/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func init() {
ClusterRegistriesNamespace: "default",
DependenciesNamespace: "default",
SecretResolver: "",
EnableRoutingPolicy: true,
EnvoyFilterVersion: "1.13",
}

p.LabelSet.WorkloadIdentityKey = "identity"
Expand Down Expand Up @@ -277,6 +279,8 @@ func TestRoutingPolicyHandler(t *testing.T) {
ClusterRegistriesNamespace: "default",
DependenciesNamespace: "default",
SecretResolver: "",
EnableRoutingPolicy: true,
EnvoyFilterVersion: "1.13",
}

p.LabelSet.WorkloadIdentityKey = "identity"
Expand All @@ -298,7 +302,7 @@ func TestRoutingPolicyHandler(t *testing.T) {
})
remoteController.RoutingPolicyController = routingPolicyController

registry.RemoteControllers = map[string]*RemoteController{"cluster-1": remoteController}
registry.remoteControllers = map[string]*RemoteController{"cluster-1": remoteController}
registry.AdmiralCache.RoutingPolicyFilterCache = rpFilterCache

// foo is dependent upon bar and bar has a deployment in the same cluster.
Expand All @@ -313,6 +317,10 @@ func TestRoutingPolicyHandler(t *testing.T) {
// foo1 is dependent upon bar 1 but bar1 does not have a deployment so it is missing from identityClusterCache
registry.AdmiralCache.IdentityDependencyCache.Put("foo1", "bar1", "bar1")

var mp = common.NewMap()
mp.Put("k1","v1")
registry.AdmiralCache.WorkloadSelectorCache.PutMap("bar"+remoteController.ClusterID, mp)
registry.AdmiralCache.WorkloadSelectorCache.PutMap("bar2differentCluster", mp)

handler.RemoteRegistry = registry

Expand All @@ -337,6 +345,7 @@ func TestRoutingPolicyHandler(t *testing.T) {
Status: v1.RoutingPolicyStatus{},
}


routingPolicyFoo1 := routingPolicyFoo.DeepCopy()
routingPolicyFoo1.Labels[common.GetWorkloadIdentifier()] = "foo1"

Expand Down Expand Up @@ -369,6 +378,7 @@ func TestRoutingPolicyHandler(t *testing.T) {

}

time.Sleep(time.Second*30)
for _, c := range testCases {
t.Run(c.name, func(t *testing.T) {
handler.Added(c.routingPolicy)
Expand All @@ -379,7 +389,7 @@ func TestRoutingPolicyHandler(t *testing.T) {
if err != nil {
t.Error("Error ocurred while computing workload Labels sha1")
}
envoyFilterName := fmt.Sprintf("%s-dynamicrouting-%s-%s", strings.ToLower(c.routingPolicy.Spec.Plugin), selectorLabelsSha, "1.10")
envoyFilterName := fmt.Sprintf("%s-dynamicrouting-%s-%s", strings.ToLower(c.routingPolicy.Spec.Plugin), selectorLabelsSha, "1.13")
filterMap := filterCacheValue[remoteController.ClusterID]
assert.NotNil(t, filterMap)
assert.NotNil(t, filterMap[envoyFilterName])
Expand All @@ -394,17 +404,19 @@ func TestRoutingPolicyHandler(t *testing.T) {
})
}



// Test for multiple filters
registry.AdmiralCache.IdentityDependencyCache.Put("foo", "bar3", "bar3")
registry.AdmiralCache.IdentityClusterCache.Put("bar3", remoteController.ClusterID, remoteController.ClusterID)

registry.AdmiralCache.WorkloadSelectorCache.PutMap("bar3"+remoteController.ClusterID, mp)
handler.Added(routingPolicyFoo)

selectorLabelsShaBar3, err := common.GetSha1("bar3"+common.GetRoutingPolicyEnv(routingPolicyFoo))
if err != nil {
t.Error("Error ocurred while computing workload Labels sha1")
}
envoyFilterNameBar3 := fmt.Sprintf("%s-dynamicrouting-%s-%s", strings.ToLower(routingPolicyFoo.Spec.Plugin), selectorLabelsShaBar3, "1.10")
envoyFilterNameBar3 := fmt.Sprintf("%s-dynamicrouting-%s-%s", strings.ToLower(routingPolicyFoo.Spec.Plugin), selectorLabelsShaBar3, "1.13")

filterCacheValue := registry.AdmiralCache.RoutingPolicyFilterCache.Get("bar3stage")
assert.NotNil(t, filterCacheValue)
Expand All @@ -415,13 +427,14 @@ func TestRoutingPolicyHandler(t *testing.T) {

registry.AdmiralCache.IdentityDependencyCache.Put("foo", "bar4", "bar4")
registry.AdmiralCache.IdentityClusterCache.Put("bar4", remoteController.ClusterID, remoteController.ClusterID)
registry.AdmiralCache.WorkloadSelectorCache.PutMap("bar4"+remoteController.ClusterID, mp)
handler.Updated(routingPolicyFoo)

selectorLabelsShaBar4, err := common.GetSha1("bar4"+common.GetRoutingPolicyEnv(routingPolicyFoo))
if err != nil {
t.Error("Error ocurred while computing workload Labels sha1")
}
envoyFilterNameBar4 := fmt.Sprintf("%s-dynamicrouting-%s-%s", strings.ToLower(routingPolicyFoo.Spec.Plugin), selectorLabelsShaBar4, "1.10")
envoyFilterNameBar4 := fmt.Sprintf("%s-dynamicrouting-%s-%s", strings.ToLower(routingPolicyFoo.Spec.Plugin), selectorLabelsShaBar4, "1.13")

filterCacheValue = registry.AdmiralCache.RoutingPolicyFilterCache.Get("bar4stage")
assert.NotNil(t, filterCacheValue)
Expand Down
2 changes: 2 additions & 0 deletions admiral/pkg/controller/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func init() {
WorkloadSidecarName: "default",
WorkloadSidecarUpdate: "disabled",
MetricsEnabled: true,
EnableRoutingPolicy: true,
EnvoyFilterVersion: "1.13",
}

p.LabelSet.WorkloadIdentityKey = "identity"
Expand Down
4 changes: 3 additions & 1 deletion admiral/pkg/controller/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ func (b AdmiralParams) String() string {
fmt.Sprintf("SecretResolver=%v ", b.SecretResolver) +
fmt.Sprintf("AdmiralStateCheckername=%v ", b.AdmiralStateCheckerName) +
fmt.Sprintf("DRStateStoreConfigPath=%v ", b.DRStateStoreConfigPath) +
fmt.Sprintf("ServiceEntryIPPrefix=%v ", b.ServiceEntryIPPrefix)
fmt.Sprintf("ServiceEntryIPPrefix=%v ", b.ServiceEntryIPPrefix) +
fmt.Sprintf("EnvoyFilterVersion=%v ", b.EnvoyFilterVersion) +
fmt.Sprintf("EnableRoutingPolicy=%v ", b.EnableRoutingPolicy)
}

type LabelSet struct {
Expand Down

0 comments on commit 904cd9c

Please sign in to comment.