AWSLambda: Don't report undefined working directory (#6585)
This commit is contained in:
parent
d3816d82da
commit
80f6cd78d1
@ -201,16 +201,16 @@ class ImageConfig:
|
|||||||
def __init__(self, config: Dict[str, Any]) -> None:
|
def __init__(self, config: Dict[str, Any]) -> None:
|
||||||
self.cmd = config.get("Command", [])
|
self.cmd = config.get("Command", [])
|
||||||
self.entry_point = config.get("EntryPoint", [])
|
self.entry_point = config.get("EntryPoint", [])
|
||||||
self.working_directory = config.get("WorkingDirectory", "")
|
self.working_directory = config.get("WorkingDirectory", None)
|
||||||
|
|
||||||
def response(self) -> Dict[str, Any]:
|
def response(self) -> Dict[str, Any]:
|
||||||
return dict(
|
content = {
|
||||||
{
|
"Command": self.cmd,
|
||||||
"Command": self.cmd,
|
"EntryPoint": self.entry_point,
|
||||||
"EntryPoint": self.entry_point,
|
}
|
||||||
"WorkingDirectory": self.working_directory,
|
if self.working_directory is not None:
|
||||||
}
|
content["WorkingDirectory"] = self.working_directory
|
||||||
)
|
return dict(content)
|
||||||
|
|
||||||
|
|
||||||
class Permission(CloudFormationModel):
|
class Permission(CloudFormationModel):
|
||||||
|
@ -228,6 +228,37 @@ def test_create_function_from_image():
|
|||||||
assert result["Configuration"]["ImageConfigResponse"]["ImageConfig"] == image_config
|
assert result["Configuration"]["ImageConfigResponse"]["ImageConfig"] == image_config
|
||||||
|
|
||||||
|
|
||||||
|
@mock_lambda
|
||||||
|
def test_create_function_from_image_default_working_directory():
|
||||||
|
conn = boto3.client("lambda", _lambda_region)
|
||||||
|
function_name = str(uuid4())[0:6]
|
||||||
|
image_uri = f"{ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/testlambdaecr:prod"
|
||||||
|
image_config = {
|
||||||
|
"EntryPoint": [
|
||||||
|
"python",
|
||||||
|
],
|
||||||
|
"Command": [
|
||||||
|
"/opt/app.py",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
conn.create_function(
|
||||||
|
FunctionName=function_name,
|
||||||
|
Role=get_role_name(),
|
||||||
|
Code={"ImageUri": image_uri},
|
||||||
|
Description="test lambda function",
|
||||||
|
ImageConfig=image_config,
|
||||||
|
PackageType="Image",
|
||||||
|
Timeout=3,
|
||||||
|
MemorySize=128,
|
||||||
|
Publish=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
result = conn.get_function(FunctionName=function_name)
|
||||||
|
|
||||||
|
assert "ImageConfigResponse" in result["Configuration"]
|
||||||
|
assert result["Configuration"]["ImageConfigResponse"]["ImageConfig"] == image_config
|
||||||
|
|
||||||
|
|
||||||
@mock_lambda
|
@mock_lambda
|
||||||
def test_create_function_error_bad_architecture():
|
def test_create_function_error_bad_architecture():
|
||||||
conn = boto3.client("lambda", _lambda_region)
|
conn = boto3.client("lambda", _lambda_region)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user