Skip to content

Commit

Permalink
Update asset references with identity
Browse files Browse the repository at this point in the history
Signed-off-by: Anubhav Aeron <anubhav_aeron@intuit.com>
  • Loading branch information
Anubhav Aeron committed Sep 28, 2022
1 parent 96185ad commit 7bdee0b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions admiral/pkg/clusters/serviceentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ func modifyServiceEntryForNewServiceOrPod(
continue
}
if deployment != nil {
if isAnExcludedAsset(common.GetDeploymentGlobalIdentifier(deployment), remoteRegistry.ExcludeIdentityList) {
log.Infof(LogFormat, event, env, sourceIdentity, clusterId, "Processing skipped as asset is in the exclude list")
if isAnExcludedIdentity(common.GetDeploymentGlobalIdentifier(deployment), remoteRegistry.ExcludeIdentityList) {
log.Infof(LogFormat, event, env, sourceIdentity, clusterId, "Processing skipped as identity is in the exclude list")
return nil
}
remoteRegistry.AdmiralCache.IdentityClusterCache.Put(sourceIdentity, rc.ClusterID, rc.ClusterID)
Expand All @@ -120,8 +120,8 @@ func modifyServiceEntryForNewServiceOrPod(
sourceDeployments[rc.ClusterID] = deployment
createServiceEntryForDeployment(ctx, event, rc, remoteRegistry.AdmiralCache, localMeshPorts, deployment, serviceEntries)
} else if rollout != nil {
if isAnExcludedAsset(common.GetRolloutGlobalIdentifier(rollout), remoteRegistry.ExcludeIdentityList) {
log.Infof(LogFormat, event, env, sourceIdentity, clusterId, "Processing skipped as asset is in the exclude list")
if isAnExcludedIdentity(common.GetRolloutGlobalIdentifier(rollout), remoteRegistry.ExcludeIdentityList) {
log.Infof(LogFormat, event, env, sourceIdentity, clusterId, "Processing skipped as identity is in the exclude list")
return nil
}
remoteRegistry.AdmiralCache.IdentityClusterCache.Put(sourceIdentity, rc.ClusterID, rc.ClusterID)
Expand Down
2 changes: 1 addition & 1 deletion admiral/pkg/clusters/serviceentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func makeGTP(name, namespace, identity, env, dnsPrefix string, creationTimestamp
}
}

func TestModifyServiceEntryForNewServiceOrPodForExcludedAsset(t *testing.T) {
func TestModifyServiceEntryForNewServiceOrPodForExcludedIdentity(t *testing.T) {
setupForServiceEntryTests()
var (
env = "test"
Expand Down
6 changes: 3 additions & 3 deletions admiral/pkg/clusters/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ func (r *RemoteRegistry) shutdown() {
}
}

func isAnExcludedAsset(assetName string, excludedIdentityList []string) bool {
for _, excludedAsset := range excludedAssetList {
if strings.EqualFold(assetName, excludedAsset) {
func isAnExcludedIdentity(assetName string, excludedIdentityList []string) bool {
for _, excludedIdentity := range excludedIdentityList {
if strings.EqualFold(assetName, excludedIdentity) {
return true
}
}
Expand Down
36 changes: 18 additions & 18 deletions admiral/pkg/clusters/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,42 +463,42 @@ func TestRoutingPolicyHandler(t *testing.T) {
assert.Nil(t, registry.AdmiralCache.RoutingPolicyFilterCache.Get("bar3stage"))
}

func TestIsAnExcludedAsset(t *testing.T) {
func TestIsAnExcludedIdentity(t *testing.T) {
testCases := []struct {
name string
assetName string
excludedAssetList []string
expectedResult bool
name string
identityName string
excludedIdentityList []string
expectedResult bool
}{
{
name: "Given an asset is in the exclude list, " +
"When isAnExcludedAsset is called, " +
name: "Given an identity is in the exclude list, " +
"When isAnExcludedIdentity is called, " +
"Then, it should return true",
assetName: "excluded-asset1",
excludedAssetList: []string{"excluded-asset1"},
expectedResult: true,
identityName: "excluded-identity1",
excludedIdentityList: []string{"excluded-identity1"},
expectedResult: true,
},
{
name: "Given an asset is NOT in the exclude list, " +
"When isAnExcludedAsset is called, " +
"When isAnExcludedIdentity is called, " +
"Then, it should return false",
assetName: "not-excluded-asset1",
excludedAssetList: []string{"excluded-asset1"},
expectedResult: false,
identityName: "not-excluded-identity1",
excludedIdentityList: []string{"excluded-identity1"},
expectedResult: false,
},
{
name: "Given an asset in the exclude list, " +
"When the asset name closely matches an excluded asset, " +
"And is different by one character, " +
"Then, it should return false",
assetName: "e1",
excludedAssetList: []string{"e2"},
expectedResult: false,
identityName: "e1",
excludedIdentityList: []string{"e2"},
expectedResult: false,
},
}

for _, c := range testCases {
result := isAnExcludedAsset(c.assetName, c.excludedAssetList)
result := isAnExcludedIdentity(c.identityName, c.excludedIdentityList)
if result != c.expectedResult {
t.Fatalf("expected: %v, got: %v", c.expectedResult, result)
}
Expand Down

0 comments on commit 7bdee0b

Please sign in to comment.