Skip to content

Commit

Permalink
renaming function to be 1 step more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
ina-stoyanova committed Oct 8, 2020
1 parent d267e39 commit ea6cf0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions aws/ecs_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/gruntwork-io/gruntwork-cli/errors"
)

// Tag an ECS cluster identified by the given cluster ARN with a tag that has the given key and value
func tagEcsCluster(awsSession *session.Session, clusterArn *string, tagKey string, tagValue string) error {
// 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 {
svc := ecs.New(awsSession)
input := &ecs.TagResourceInput{
ResourceArn: clusterArn,
Expand Down Expand Up @@ -53,7 +53,7 @@ func getAllEcsClustersOlderThan(awsSession *session.Session, region string, excl
}

if firstSeenTime.IsZero() {
err := tagEcsCluster(awsSession, clusterArn, firstSeenTagKey, time.Now().UTC().Format(time.RFC3339))
err := tagEcsClusterWhenFirstSeen(awsSession, clusterArn, firstSeenTagKey, 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
16 changes: 8 additions & 8 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 := tagEcsCluster(awsSession, cluster.ClusterArn, firstSeenTagKey, tagValue)
tagErr := tagEcsClusterWhenFirstSeen(awsSession, cluster.ClusterArn, firstSeenTagKey, 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 := tagEcsCluster(awsSession, cluster1.ClusterArn, firstSeenTagKey, olderClusterTagValue)
err1 := tagEcsClusterWhenFirstSeen(awsSession, cluster1.ClusterArn, firstSeenTagKey, olderClusterTagValue)
require.NoError(t, err1)
err2 := tagEcsCluster(awsSession, cluster2.ClusterArn, firstSeenTagKey, youngerClusterTagValue)
err2 := tagEcsClusterWhenFirstSeen(awsSession, cluster2.ClusterArn, firstSeenTagKey, 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 := tagEcsCluster(awsSession, cluster1.ClusterArn, firstSeenTagKey, oldClusterTagValue1)
require.NoError(t, err1)
err2 := tagEcsCluster(awsSession, cluster2.ClusterArn, firstSeenTagKey, youngClusterTagValue)
require.NoError(t, err2)
err3 := tagEcsCluster(awsSession, cluster3.ClusterArn, firstSeenTagKey, oldClusterTagValue2)
err1 := tagEcsClusterWhenFirstSeen(awsSession, cluster1.ClusterArn, firstSeenTagKey, oldClusterTagValue1)
require.NoError(t, err1)
err2 := tagEcsClusterWhenFirstSeen(awsSession, cluster2.ClusterArn, firstSeenTagKey, youngClusterTagValue)
require.NoError(t, err2)
err3 := tagEcsClusterWhenFirstSeen(awsSession, cluster3.ClusterArn, firstSeenTagKey, oldClusterTagValue2)
require.NoError(t, err3)

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

0 comments on commit ea6cf0d

Please sign in to comment.