Skip to content

Commit

Permalink
JSON schema improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
adammcdonagh authored Jun 21, 2024
1 parent 9f5c398 commit dd35be7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v24.25.2

- Allow blank postCopyAction, or "none". This can be useful when using the same job definition for multiple environments and are using a variable to control the PCA. This way you can set the variable to "none" in the environment where you don't want it to run.
- Also prevent S3 source directories from starting or ending with a /

## v24.25.1

- Add possibility for encryption to the s3 schemas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},
"directory": {
"type": "string",
"default": ""
"default": "",
"pattern": "^(?!/)(?!.*/$).*$"
},
"fileRegex": {
"type": "string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"properties": {
"action": {
"type": "string",
"enum": ["move", "rename", "delete"]
"enum": ["move", "rename", "delete", "", "none"]
},
"destination": {
"type": "string"
Expand All @@ -31,9 +31,16 @@
"required": ["action", "destination"]
},
"else": {
"properties": {
"destination": {
"not": {}
"if": {
"properties": {
"action": {
"enum": ["move", "rename"]
}
}
},
"then": {
"not": {
"required": ["destination"]
}
}
}
Expand Down
28 changes: 27 additions & 1 deletion tests/test_s3_source_schema_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def valid_protocol_definition_using_assume_role_and_keys():
def valid_transfer(valid_protocol_definition):
return {
"bucket": "test-bucket",
"directory": "/src",
"directory": "src",
"fileRegex": ".*\\.txt",
"protocol": valid_protocol_definition,
}
Expand Down Expand Up @@ -99,6 +99,16 @@ def test_s3_source_basic(valid_transfer):

assert validate_transfer_json(json_data)

# Add / to the directory and validate it fails
json_data["source"]["directory"] = "/src/"
assert not validate_transfer_json(json_data)

json_data["source"]["directory"] = "/src"
assert not validate_transfer_json(json_data)

json_data["source"]["directory"] = "src/"
assert not validate_transfer_json(json_data)

# Remove protocol
del json_data["source"]["protocol"]
assert not validate_transfer_json(json_data)
Expand Down Expand Up @@ -161,6 +171,22 @@ def test_s3_post_copy_action(valid_transfer):
json_data["source"]["postCopyAction"]["destination"] = "/"
assert validate_transfer_json(json_data)

json_data["source"]["postCopyAction"] = {
"action": "",
}
assert validate_transfer_json(json_data)

json_data["source"]["postCopyAction"] = {
"action": "none",
"destination": "s3://test-bucket/dest",
}
assert validate_transfer_json(json_data)

json_data["source"]["postCopyAction"] = {
"action": "invalid",
}
assert not validate_transfer_json(json_data)


def test_s3_destination(valid_transfer, valid_destination):
json_data = {
Expand Down

0 comments on commit dd35be7

Please sign in to comment.