Skip to content

Commit

Permalink
feat: support python 3.11 (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
astuyve authored Aug 1, 2023
1 parent 80d7149 commit 9b10690
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 @@ -48,6 +48,7 @@ export const runtimeLookup: { [key: string]: RuntimeType } = {
"python3.8": RuntimeType.PYTHON,
"python3.9": RuntimeType.PYTHON,
"python3.10": RuntimeType.PYTHON,
"python3.11": RuntimeType.PYTHON,
};

function runtimeToLayerName(runtime: string, architecture: string): string {
Expand All @@ -65,12 +66,14 @@ function runtimeToLayerName(runtime: string, architecture: string): string {
"python3.8": "Datadog-Python38",
"python3.9": "Datadog-Python39",
"python3.10": "Datadog-Python310",
"python3.11": "Datadog-Python311",
};

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",
};

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 @@ -60,6 +60,7 @@ describe("findLambdas", () => {
Python38Function: mockFunctionResource("python3.8", ["x86_64"]),
Python39Function: mockFunctionResource("python3.9", ["x86_64"]),
Python310Function: mockFunctionResource("python3.10", ["x86_64"]),
Python311Function: mockFunctionResource("python3.11", ["x86_64"]),
GoFunction: mockFunctionResource("go1.10", ["x86_64"]),
RefFunction: mockFunctionResource({ Ref: "ValueRef" }, ["arm64"]),
};
Expand All @@ -76,6 +77,7 @@ describe("findLambdas", () => {
mockLambdaFunction("Python38Function", "python3.8", RuntimeType.PYTHON, "x86_64", ArchitectureType.x86_64),
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("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 @@ -188,15 +190,15 @@ describe("applyLayers", () => {
});

it("applies the python and extension lambda layers for arm", () => {
const lambda = mockLambdaFunction("FunctionKey", "python3.10", RuntimeType.PYTHON, "arm64", ArchitectureType.ARM64);
const lambda = mockLambdaFunction("FunctionKey", "python3.11", RuntimeType.PYTHON, "arm64", ArchitectureType.ARM64);
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-Python310-ARM:${pythonLayerVersion}`,
`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Python311-ARM:${pythonLayerVersion}`,
`arn:aws:lambda:${region}:${DD_ACCOUNT_ID}:layer:Datadog-Extension-ARM:${extensionLayerVersion}`,
]);
});
Expand Down

0 comments on commit 9b10690

Please sign in to comment.