From 4f552a4ebb3e98f198bb127bace80b3ecca2a4cf Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 21 Sep 2023 15:20:02 -0400 Subject: [PATCH] add enforce comment length --- packaging/uniformBuild/aws_utils.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packaging/uniformBuild/aws_utils.go b/packaging/uniformBuild/aws_utils.go index ab2f05d2a9..7d98673955 100644 --- a/packaging/uniformBuild/aws_utils.go +++ b/packaging/uniformBuild/aws_utils.go @@ -263,7 +263,13 @@ func StopInstanceCmd(client *ec2.Client, instanceID string) error { fmt.Println("Stopped instance with ID " + instanceID) return nil } - +func enforceCommentLimit(s string) string { + const commentCharLimit = 100 + if len(s) > commentCharLimit { + return s[:commentCharLimit] + } + return s +} func RunCmdRemotely(ssmClient *ssm.Client, instance *types.Instance, command string, comment string) error { // Specify the input for sending the command timeout := int32(COMMAND_TRACKING_TIMEOUT.Seconds()) @@ -281,7 +287,7 @@ func RunCmdRemotely(ssmClient *ssm.Client, instance *types.Instance, command str OutputS3KeyPrefix: aws.String("buildenvtesting/logs/"), TimeoutSeconds: aws.Int32(timeout), - Comment: aws.String(comment), + Comment: aws.String(enforceCommentLimit(comment)), } // Run the script on the instance fmt.Println("Command sent!")