Skip to content

Commit

Permalink
removing unnecessary references to tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ina-stoyanova committed Oct 9, 2020
1 parent ea6cf0d commit 34cae6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions aws/ecs_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
)

// Tag an ECS cluster identified by the given cluster ARN when it's first seen by cloud-nuke
func tagEcsClusterWhenFirstSeen(awsSession *session.Session, clusterArn *string, tagKey string, tagValue string) error {
func tagEcsClusterWhenFirstSeen(awsSession *session.Session, clusterArn *string, tagValue string) error {
svc := ecs.New(awsSession)
input := &ecs.TagResourceInput{
ResourceArn: clusterArn,
Tags: []*ecs.Tag{
{
Key: aws.String(tagKey),
Key: aws.String(firstSeenTagKey),
Value: aws.String(tagValue),
},
},
Expand Down Expand Up @@ -53,7 +53,7 @@ func getAllEcsClustersOlderThan(awsSession *session.Session, region string, excl
}

if firstSeenTime.IsZero() {
err := tagEcsClusterWhenFirstSeen(awsSession, clusterArn, firstSeenTagKey, time.Now().UTC().Format(time.RFC3339))
err := tagEcsClusterWhenFirstSeen(awsSession, clusterArn, time.Now().UTC().Format(time.RFC3339))
if err != nil {
logging.Logger.Errorf("Error tagigng the ECS cluster with ARN %s", aws.StringValue(clusterArn))
return nil, errors.WithStackTrace(err)
Expand Down
12 changes: 6 additions & 6 deletions aws/ecs_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestCanTagEcsClusters(t *testing.T) {

tagValue := time.Now().UTC().Format(time.RFC3339)

tagErr := tagEcsClusterWhenFirstSeen(awsSession, cluster.ClusterArn, firstSeenTagKey, tagValue)
tagErr := tagEcsClusterWhenFirstSeen(awsSession, cluster.ClusterArn, tagValue)
require.NoError(t, tagErr)

returnedTag, err := getClusterTag(awsSession, cluster.ClusterArn, firstSeenTagKey)
Expand All @@ -54,9 +54,9 @@ func TestCanListAllEcsClustersOlderThan24hours(t *testing.T) {
var olderClusterTagValue = now.Add(time.Hour * time.Duration(-48)).Format(time.RFC3339)
var youngerClusterTagValue = now.Add(time.Hour * time.Duration(-23)).Format(time.RFC3339)

err1 := tagEcsClusterWhenFirstSeen(awsSession, cluster1.ClusterArn, firstSeenTagKey, olderClusterTagValue)
err1 := tagEcsClusterWhenFirstSeen(awsSession, cluster1.ClusterArn, olderClusterTagValue)
require.NoError(t, err1)
err2 := tagEcsClusterWhenFirstSeen(awsSession, cluster2.ClusterArn, firstSeenTagKey, youngerClusterTagValue)
err2 := tagEcsClusterWhenFirstSeen(awsSession, cluster2.ClusterArn, youngerClusterTagValue)
require.NoError(t, err2)

last24Hours := now.Add(time.Hour * time.Duration(-24))
Expand Down Expand Up @@ -87,11 +87,11 @@ func TestCanNukeAllEcsClustersOlderThan24Hours(t *testing.T) {
var youngClusterTagValue = now.Format(time.RFC3339)
var oldClusterTagValue2 = now.Add(time.Hour * time.Duration(-27)).Format(time.RFC3339)

err1 := tagEcsClusterWhenFirstSeen(awsSession, cluster1.ClusterArn, firstSeenTagKey, oldClusterTagValue1)
err1 := tagEcsClusterWhenFirstSeen(awsSession, cluster1.ClusterArn, oldClusterTagValue1)
require.NoError(t, err1)
err2 := tagEcsClusterWhenFirstSeen(awsSession, cluster2.ClusterArn, firstSeenTagKey, youngClusterTagValue)
err2 := tagEcsClusterWhenFirstSeen(awsSession, cluster2.ClusterArn, youngClusterTagValue)
require.NoError(t, err2)
err3 := tagEcsClusterWhenFirstSeen(awsSession, cluster3.ClusterArn, firstSeenTagKey, oldClusterTagValue2)
err3 := tagEcsClusterWhenFirstSeen(awsSession, cluster3.ClusterArn, oldClusterTagValue2)
require.NoError(t, err3)

last24Hours := now.Add(time.Hour * time.Duration(-24))
Expand Down

0 comments on commit 34cae6f

Please sign in to comment.