Skip to content

Commit f9a6eec

Browse files
committed
updating key value tag with their constant variables
1 parent 63240b6 commit f9a6eec

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

pkg/awsutils/awsutils_test.go

+44-44
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
13761376
Filters: []ec2types.Filter{
13771377
{
13781378
Name: aws.String("tag-key"),
1379-
Values: []string{"node.k8s.amazonaws.com/instance_id"},
1379+
Values: []string{eniNodeTagKey},
13801380
},
13811381
{
13821382
Name: aws.String("status"),
@@ -1409,7 +1409,7 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
14091409
Filters: []ec2types.Filter{
14101410
{
14111411
Name: aws.String("tag-key"),
1412-
Values: []string{"node.k8s.amazonaws.com/instance_id"},
1412+
Values: []string{eniNodeTagKey},
14131413
},
14141414
{
14151415
Name: aws.String("status"),
@@ -1431,11 +1431,11 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
14311431
Status: "available",
14321432
TagSet: []ec2types.Tag{
14331433
{
1434-
Key: aws.String("node.k8s.amazonaws.com/instance_id"),
1434+
Key: aws.String(eniNodeTagKey),
14351435
Value: aws.String("i-xxxxx"),
14361436
},
14371437
{
1438-
Key: aws.String("node.k8s.amazonaws.com/createdAt"),
1438+
Key: aws.String(eniCreatedAtTagKey),
14391439
Value: aws.String(tenMinuteAgo.Format(time.RFC3339)),
14401440
},
14411441
},
@@ -1453,11 +1453,11 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
14531453
Status: "available",
14541454
TagSet: []ec2types.Tag{
14551455
{
1456-
Key: aws.String("node.k8s.amazonaws.com/instance_id"),
1456+
Key: aws.String(eniNodeTagKey),
14571457
Value: aws.String("i-xxxxx"),
14581458
},
14591459
{
1460-
Key: aws.String("node.k8s.amazonaws.com/createdAt"),
1460+
Key: aws.String(eniCreatedAtTagKey),
14611461
Value: aws.String(tenMinuteAgo.Format(time.RFC3339)),
14621462
},
14631463
},
@@ -1474,7 +1474,7 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
14741474
Filters: []ec2types.Filter{
14751475
{
14761476
Name: aws.String("tag-key"),
1477-
Values: []string{"node.k8s.amazonaws.com/instance_id"},
1477+
Values: []string{eniNodeTagKey},
14781478
},
14791479
{
14801480
Name: aws.String("status"),
@@ -1496,11 +1496,11 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
14961496
Status: "available",
14971497
TagSet: []ec2types.Tag{
14981498
{
1499-
Key: aws.String("node.k8s.amazonaws.com/instance_id"),
1499+
Key: aws.String(eniNodeTagKey),
15001500
Value: aws.String("i-xxxxx"),
15011501
},
15021502
{
1503-
Key: aws.String("node.k8s.amazonaws.com/createdAt"),
1503+
Key: aws.String(eniCreatedAtTagKey),
15041504
Value: aws.String(tenMinuteAgo.Format(time.RFC3339)),
15051505
},
15061506
},
@@ -1523,7 +1523,7 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
15231523
Filters: []ec2types.Filter{
15241524
{
15251525
Name: aws.String("tag-key"),
1526-
Values: []string{"node.k8s.amazonaws.com/instance_id"},
1526+
Values: []string{eniNodeTagKey},
15271527
},
15281528
{
15291529
Name: aws.String("status"),
@@ -1545,11 +1545,11 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
15451545
Status: "available",
15461546
TagSet: []ec2types.Tag{
15471547
{
1548-
Key: aws.String("node.k8s.amazonaws.com/instance_id"),
1548+
Key: aws.String(eniNodeTagKey),
15491549
Value: aws.String("i-xxxxx"),
15501550
},
15511551
{
1552-
Key: aws.String("node.k8s.amazonaws.com/createdAt"),
1552+
Key: aws.String(eniCreatedAtTagKey),
15531553
Value: aws.String(now.Format(time.RFC3339)),
15541554
},
15551555
},
@@ -1572,7 +1572,7 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
15721572
Filters: []ec2types.Filter{
15731573
{
15741574
Name: aws.String("tag-key"),
1575-
Values: []string{"node.k8s.amazonaws.com/instance_id"},
1575+
Values: []string{eniNodeTagKey},
15761576
},
15771577
{
15781578
Name: aws.String("status"),
@@ -1605,7 +1605,7 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
16051605
Filters: []ec2types.Filter{
16061606
{
16071607
Name: aws.String("tag-key"),
1608-
Values: []string{"node.k8s.amazonaws.com/instance_id"},
1608+
Values: []string{eniNodeTagKey},
16091609
},
16101610
{
16111611
Name: aws.String("status"),
@@ -1631,15 +1631,15 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
16311631
Status: "available",
16321632
TagSet: []ec2types.Tag{
16331633
{
1634-
Key: aws.String("node.k8s.amazonaws.com/instance_id"),
1634+
Key: aws.String(eniNodeTagKey),
16351635
Value: aws.String("i-xxxxx"),
16361636
},
16371637
{
1638-
Key: aws.String("node.k8s.amazonaws.com/createdAt"),
1638+
Key: aws.String(eniCreatedAtTagKey),
16391639
Value: aws.String(tenMinuteAgo.Format(time.RFC3339)),
16401640
},
16411641
{
1642-
Key: aws.String("cluster.k8s.amazonaws.com/name"),
1642+
Key: aws.String(eniClusterTagKey),
16431643
Value: aws.String("awesome-cluster"),
16441644
},
16451645
},
@@ -1657,15 +1657,15 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
16571657
Status: "available",
16581658
TagSet: []ec2types.Tag{
16591659
{
1660-
Key: aws.String("node.k8s.amazonaws.com/instance_id"),
1660+
Key: aws.String(eniNodeTagKey),
16611661
Value: aws.String("i-xxxxx"),
16621662
},
16631663
{
1664-
Key: aws.String("node.k8s.amazonaws.com/createdAt"),
1664+
Key: aws.String(eniCreatedAtTagKey),
16651665
Value: aws.String(tenMinuteAgo.Format(time.RFC3339)),
16661666
},
16671667
{
1668-
Key: aws.String("cluster.k8s.amazonaws.com/name"),
1668+
Key: aws.String(eniClusterTagKey),
16691669
Value: aws.String("awesome-cluster"),
16701670
},
16711671
},
@@ -1682,7 +1682,7 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
16821682
Filters: []ec2types.Filter{
16831683
{
16841684
Name: aws.String("tag-key"),
1685-
Values: []string{"node.k8s.amazonaws.com/instance_id"},
1685+
Values: []string{eniNodeTagKey},
16861686
},
16871687
{
16881688
Name: aws.String("status"),
@@ -1708,15 +1708,15 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
17081708
Status: "available",
17091709
TagSet: []ec2types.Tag{
17101710
{
1711-
Key: aws.String("node.k8s.amazonaws.com/instance_id"),
1711+
Key: aws.String(eniNodeTagKey),
17121712
Value: aws.String("i-xxxxx"),
17131713
},
17141714
{
1715-
Key: aws.String("node.k8s.amazonaws.com/createdAt"),
1715+
Key: aws.String(eniCreatedAtTagKey),
17161716
Value: aws.String(tenMinuteAgo.Format(time.RFC3339)),
17171717
},
17181718
{
1719-
Key: aws.String("cluster.k8s.amazonaws.com/name"),
1719+
Key: aws.String(eniClusterTagKey),
17201720
Value: aws.String("awesome-cluster"),
17211721
},
17221722
},
@@ -1739,7 +1739,7 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
17391739
Filters: []ec2types.Filter{
17401740
{
17411741
Name: aws.String("tag-key"),
1742-
Values: []string{"node.k8s.amazonaws.com/instance_id"},
1742+
Values: []string{eniNodeTagKey},
17431743
},
17441744
{
17451745
Name: aws.String("status"),
@@ -1765,15 +1765,15 @@ func TestEC2InstanceMetadataCache_getLeakedENIs(t *testing.T) {
17651765
Status: "available",
17661766
TagSet: []ec2types.Tag{
17671767
{
1768-
Key: aws.String("node.k8s.amazonaws.com/instance_id"),
1768+
Key: aws.String(eniNodeTagKey),
17691769
Value: aws.String("i-xxxxx"),
17701770
},
17711771
{
1772-
Key: aws.String("node.k8s.amazonaws.com/createdAt"),
1772+
Key: aws.String(eniCreatedAtTagKey),
17731773
Value: aws.String(now.Format(time.RFC3339)),
17741774
},
17751775
{
1776-
Key: aws.String("cluster.k8s.amazonaws.com/name"),
1776+
Key: aws.String(eniClusterTagKey),
17771777
Value: aws.String("awesome-cluster"),
17781778
},
17791779
},
@@ -1853,15 +1853,15 @@ func TestEC2InstanceMetadataCache_TagENI(t *testing.T) {
18531853
Resources: []string{"eni-xxxx"},
18541854
Tags: []ec2types.Tag{
18551855
{
1856-
Key: aws.String("cluster.k8s.amazonaws.com/name"),
1856+
Key: aws.String(eniClusterTagKey),
18571857
Value: aws.String("awesome-cluster"),
18581858
},
18591859
{
1860-
Key: aws.String("eks:eni:owner"),
1861-
Value: aws.String("amazon-vpc-cni"),
1860+
Key: aws.String(eniOwnerTagKey),
1861+
Value: aws.String(eniOwnerTagValue),
18621862
},
18631863
{
1864-
Key: aws.String("node.k8s.amazonaws.com/instance_id"),
1864+
Key: aws.String(eniNodeTagKey),
18651865
Value: aws.String("i-xxxx"),
18661866
},
18671867
},
@@ -1885,9 +1885,9 @@ func TestEC2InstanceMetadataCache_TagENI(t *testing.T) {
18851885
args: args{
18861886
eniID: "eni-xxxx",
18871887
currentTags: map[string]string{
1888-
"node.k8s.amazonaws.com/instance_id": "i-xxxx",
1889-
"cluster.k8s.amazonaws.com/name": "awesome-cluster",
1890-
"eks:eni:owner": "amazon-vpc-cni",
1888+
eniNodeTagKey: "i-xxxx",
1889+
eniClusterTagKey: "awesome-cluster",
1890+
eniOwnerTagKey: eniOwnerTagValue,
18911891
},
18921892
},
18931893
wantErr: nil,
@@ -1903,12 +1903,12 @@ func TestEC2InstanceMetadataCache_TagENI(t *testing.T) {
19031903
Resources: []string{"eni-xxxx"},
19041904
Tags: []ec2types.Tag{
19051905
{
1906-
Key: aws.String("cluster.k8s.amazonaws.com/name"),
1906+
Key: aws.String(eniClusterTagKey),
19071907
Value: aws.String("awesome-cluster"),
19081908
},
19091909
{
1910-
Key: aws.String("eks:eni:owner"),
1911-
Value: aws.String("amazon-vpc-cni"),
1910+
Key: aws.String(eniOwnerTagKey),
1911+
Value: aws.String(eniOwnerTagValue),
19121912
},
19131913
},
19141914
},
@@ -1918,8 +1918,8 @@ func TestEC2InstanceMetadataCache_TagENI(t *testing.T) {
19181918
args: args{
19191919
eniID: "eni-xxxx",
19201920
currentTags: map[string]string{
1921-
"node.k8s.amazonaws.com/instance_id": "i-xxxx",
1922-
"anotherKey": "anotherDay",
1921+
eniNodeTagKey: "i-xxxx",
1922+
"anotherKey": "anotherDay",
19231923
},
19241924
},
19251925
wantErr: nil,
@@ -1935,15 +1935,15 @@ func TestEC2InstanceMetadataCache_TagENI(t *testing.T) {
19351935
Resources: []string{"eni-xxxx"},
19361936
Tags: []ec2types.Tag{
19371937
{
1938-
Key: aws.String("cluster.k8s.amazonaws.com/name"),
1938+
Key: aws.String(eniClusterTagKey),
19391939
Value: aws.String("awesome-cluster"),
19401940
},
19411941
{
1942-
Key: aws.String("eks:eni:owner"),
1943-
Value: aws.String("amazon-vpc-cni"),
1942+
Key: aws.String(eniOwnerTagKey),
1943+
Value: aws.String(eniOwnerTagValue),
19441944
},
19451945
{
1946-
Key: aws.String("node.k8s.amazonaws.com/instance_id"),
1946+
Key: aws.String(eniNodeTagKey),
19471947
Value: aws.String("i-xxxx"),
19481948
},
19491949
},

0 commit comments

Comments
 (0)