From 28aac84e0698ba117b3ae0da0d6412dd0bcae3ce Mon Sep 17 00:00:00 2001 From: Will Fu <115735916+www-fu@users.noreply.github.com> Date: Mon, 23 Sep 2024 08:19:31 -0400 Subject: [PATCH] Add missing null check to tag translator method (#69) * Add missing null check to tag translator method * Move check to handler to avoid ambiguous code * Remove erroneous contract-test-artifacts --- .../amazon/transfer/server/CreateHandler.java | 2 +- .../contract-tests-artifacts/dependencies.yml | 36 ---- .../contract-tests-artifacts/inputs_1.json | 187 ------------------ 3 files changed, 1 insertion(+), 224 deletions(-) delete mode 100644 aws-transfer-workflow/contract-tests-artifacts/dependencies.yml delete mode 100644 aws-transfer-workflow/contract-tests-artifacts/inputs_1.json diff --git a/aws-transfer-server/src/main/java/software/amazon/transfer/server/CreateHandler.java b/aws-transfer-server/src/main/java/software/amazon/transfer/server/CreateHandler.java index 3fe5597..9aa5214 100644 --- a/aws-transfer-server/src/main/java/software/amazon/transfer/server/CreateHandler.java +++ b/aws-transfer-server/src/main/java/software/amazon/transfer/server/CreateHandler.java @@ -81,7 +81,7 @@ private CreateServerRequest translateToCreateRequest(final ResourceModel model) .protocols(translateToSdkProtocols(model.getProtocols())) .protocolDetails(ProtocolDetailsTranslator.toSdk(model.getProtocolDetails())) .securityPolicyName(model.getSecurityPolicyName()) - .tags(translateToSdkTags(model.getTags())) + .tags(CollectionUtils.isNullOrEmpty(model.getTags()) ? null : translateToSdkTags(model.getTags())) .workflowDetails(WorkflowDetailsTranslator.toSdk(model.getWorkflowDetails(), false)) .structuredLogDestinations(model.getStructuredLogDestinations()) .s3StorageOptions(S3StorageOptionsTranslator.toSdk(model.getS3StorageOptions())) diff --git a/aws-transfer-workflow/contract-tests-artifacts/dependencies.yml b/aws-transfer-workflow/contract-tests-artifacts/dependencies.yml deleted file mode 100644 index 3fd1209..0000000 --- a/aws-transfer-workflow/contract-tests-artifacts/dependencies.yml +++ /dev/null @@ -1,36 +0,0 @@ -Resources: - WorkflowsLambdaExecutionRole: - Type: AWS::IAM::Role - Properties: - AssumeRolePolicyDocument: - Version: '2012-10-17' - Statement: - - Effect: Allow - Principal: - Service: - - lambda.amazonaws.com - Action: - - sts:AssumeRole - ManagedPolicyArns: - - Fn::Sub: arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaRole - WorkflowsCustomStepLambda: - Type: AWS::Lambda::Function - Properties: - Code: - ZipFile: | - def handler(event, context): - print(event) - - return { - 'message': 'Hello, world' - } - Handler: index.handler - Role: - Fn::GetAtt: WorkflowsLambdaExecutionRole.Arn - Runtime: python3.11 -Outputs: - WorkflowsCustomStepLambda: - Value: - Fn::GetAtt: WorkflowsCustomStepLambda.Arn - Export: - Name: awstransferworkflowcto1 diff --git a/aws-transfer-workflow/contract-tests-artifacts/inputs_1.json b/aws-transfer-workflow/contract-tests-artifacts/inputs_1.json deleted file mode 100644 index d03260a..0000000 --- a/aws-transfer-workflow/contract-tests-artifacts/inputs_1.json +++ /dev/null @@ -1,187 +0,0 @@ -{ - "CreateInputs": { - "Description": "aws-transfer-ct", - "OnExceptionSteps": [ - { - "Type": "DELETE", - "DeleteStepDetails": { - "Name": "deleteallfiles", - "SourceFileLocation": "${previous.file}" - } - }, - { - "Type": "COPY", - "CopyStepDetails": { - "Name": "copyToS3Folder", - "DestinationFileLocation": { - "S3FileLocation": { - "Bucket": "test", - "Key": "test/" - } - }, - "OverwriteExisting": "FALSE", - "SourceFileLocation": "${previous.file}" - } - }, - { - "Type": "DECRYPT", - "DecryptStepDetails": { - "Name": "decrypttofolder", - "Type": "PGP", - "DestinationFileLocation": { - "S3FileLocation": { - "Bucket": "test", - "Key": "test/" - } - }, - "OverwriteExisting": "FALSE", - "SourceFileLocation": "${previous.file}" - } - }, - { - "Type": "DECRYPT", - "DecryptStepDetails": { - "Name": "decrypttofolder", - "Type": "PGP", - "DestinationFileLocation": { - "EfsFileLocation": { - "FileSystemId": "arn:aws:elasticfilesystem:us-east-1:1111333322228888:file-system/fs-0123456789abcdef8", - "Path": "test/" - } - }, - "OverwriteExisting": "FALSE", - "SourceFileLocation": "${previous.file}" - } - }, - { - "Type": "TAG", - "TagStepDetails": { - "Name": "tagfile", - "Tags": [ - { - "Key": "key1", - "Value": "value1" - }, - { - "Key": "key2", - "Value": "value2" - } - ], - "SourceFileLocation": "${previous.file}" - } - }, - { - "Type": "CUSTOM", - "CustomStepDetails": { - "Name": "customit", - "Target": "{{awstransferworkflowcto1}}", - "TimeoutSeconds": 10 - } - } - ], - "Steps": [ - { - "Type": "DELETE", - "DeleteStepDetails": { - "Name": "deleteallfiles", - "SourceFileLocation": "${previous.file}" - } - }, - { - "Type": "COPY", - "CopyStepDetails": { - "Name": "copyToS3Folder", - "DestinationFileLocation": { - "S3FileLocation": { - "Bucket": "test", - "Key": "test/" - } - }, - "OverwriteExisting": "FALSE", - "SourceFileLocation": "${previous.file}" - } - }, - { - "Type": "DECRYPT", - "DecryptStepDetails": { - "Name": "decryptToS3Folder", - "Type": "PGP", - "DestinationFileLocation": { - "S3FileLocation": { - "Bucket": "test", - "Key": "test/" - } - }, - "OverwriteExisting": "FALSE", - "SourceFileLocation": "${previous.file}" - } - }, - { - "Type": "DECRYPT", - "DecryptStepDetails": { - "Name": "decryptToEfsFolder", - "Type": "PGP", - "DestinationFileLocation": { - "EfsFileLocation": { - "FileSystemId": "arn:aws:elasticfilesystem:us-east-1:1111333322228888:file-system/fs-0123456789abcdef8", - "Path": "test/" - } - }, - "OverwriteExisting": "FALSE", - "SourceFileLocation": "${previous.file}" - } - }, - { - "Type": "TAG", - "TagStepDetails": { - "Name": "tagfile", - "Tags": [ - { - "Key": "key1", - "Value": "value1" - }, - { - "Key": "key2", - "Value": "value2" - } - ], - "SourceFileLocation": "${previous.file}" - } - }, - { - "Type": "CUSTOM", - "CustomStepDetails": { - "Name": "customit", - "Target": "{{awstransferworkflowcto1}}", - "TimeoutSeconds": 10 - } - } - ], - "Tags": [ - { - "Key": "apple", - "Value": "red" - }, - { - "Key": "peach", - "Value": "pink" - } - ] - }, - "PatchInputs": [ - { - "op": "replace", - "path": "/Tags/0/Key", - "value": "xfer" - }, - { - "op": "replace", - "path": "/Tags/0/Value", - "value": "yay" - }, - { - "op": "remove", - "path": "/Tags/1" - } - ] -}