Skip to content

Commit

Permalink
add python3.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanista committed Jan 5, 2024
1 parent a45b80c commit 45011ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions serverless/src/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const runtimeLookup: { [key: string]: RuntimeType } = {
"python3.9": RuntimeType.PYTHON,
"python3.10": RuntimeType.PYTHON,
"python3.11": RuntimeType.PYTHON,
"python3.12": RuntimeType.PYTHON,
};

function runtimeToLayerName(runtime: string, architecture: string): string {
Expand All @@ -69,13 +70,15 @@ function runtimeToLayerName(runtime: string, architecture: string): string {
"python3.9": "Datadog-Python39",
"python3.10": "Datadog-Python310",
"python3.11": "Datadog-Python311",
"python3.12": "Datadog-Python312",
};

const pythonArmLookup: { [key: string]: string } = {
"python3.8": "Datadog-Python38-ARM",
"python3.9": "Datadog-Python39-ARM",
"python3.10": "Datadog-Python310-ARM",
"python3.11": "Datadog-Python311-ARM",
"python3.12": "Datadog-Python312-ARM",
};

if (runtimeLookup[runtime] === RuntimeType.NODE) {
Expand Down
6 changes: 4 additions & 2 deletions serverless/test/layer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe("findLambdas", () => {
Python39Function: mockFunctionResource("python3.9", ["x86_64"]),
Python310Function: mockFunctionResource("python3.10", ["x86_64"]),
Python311Function: mockFunctionResource("python3.11", ["x86_64"]),
Python312Function: mockFunctionResource("python3.12", ["x86_64"]),
GoFunction: mockFunctionResource("go1.10", ["x86_64"]),
RefFunction: mockFunctionResource({ Ref: "ValueRef" }, ["arm64"]),
};
Expand All @@ -80,6 +81,7 @@ describe("findLambdas", () => {
mockLambdaFunction("Python39Function", "python3.9", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Python310Function", "python3.10", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Python311Function", "python3.11", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("Python312Function", "python3.12", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("GoFunction", "go1.10", RuntimeType.UNSUPPORTED, "x86_64", ArchitectureType.x86_64),
mockLambdaFunction("RefFunction", "nodejs14.x", RuntimeType.NODE, "arm64", ArchitectureType.ARM64, {
Ref: "ValueRef",
Expand Down Expand Up @@ -178,15 +180,15 @@ describe("applyLayers", () => {
});

it("applies the python and extension lambda layers", () => {
const lambda = mockLambdaFunction("FunctionKey", "python3.6", RuntimeType.PYTHON, "x86_64");
const lambda = mockLambdaFunction("FunctionKey", "python3.12", RuntimeType.PYTHON, "x86_64");
const region = "us-east-1";
const pythonLayerVersion = 25;
const extensionLayerVersion = 6;
const errors = applyLayers(region, [lambda], pythonLayerVersion, undefined, extensionLayerVersion);

expect(errors.length).toEqual(0);
expect(lambda.properties.Layers).toEqual([
`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Python36:${pythonLayerVersion}`,
`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Python312:${pythonLayerVersion}`,
`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Extension:${extensionLayerVersion}`,
]);
});
Expand Down

0 comments on commit 45011ef

Please sign in to comment.