Skip to content

Commit 33fd9c7

Browse files
authored
Add Function layers support (#35)
Part of aws-controllers-k8s/community#1062 Description of changes: - Bring back the `Spec.Layers` field - Add a new field called `LayersReference` in status to store the layers references returned by the Lambda control plane - Add hooks to properly set `Status.LayersReference` after a create and a read call By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent b6cad91 commit 33fd9c7

File tree

11 files changed

+185
-62
lines changed

11 files changed

+185
-62
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2022-04-15T17:24:14Z"
3-
build_hash: 50c64871bcaf88b9ee200eb8d6b8245fa8f675eb
4-
go_version: go1.17.5
5-
version: v0.18.4
6-
api_directory_checksum: a704674d4df0400198d5a11035a2099240bccf80
2+
build_date: "2022-04-27T16:40:07Z"
3+
build_hash: 141cb9db73f881228ea20e572de3ba9df19d5b6f
4+
go_version: go1.18.1
5+
version: v0.18.4-4-g141cb9d-dirty
6+
api_directory_checksum: 7c4e0f8971a8ab06389e98b21c00eddad87366f3
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.42.0
99
generator_config_info:
10-
file_checksum: f04b298afa1fd7fd3980226d52412de9ca1523d4
10+
file_checksum: c48a2acfc8da0b28ee9b81745b9af773d10c7f71
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/function.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/generator.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ ignore:
44
# Alias
55
# CodeSigningConfig
66
# EventSourceMapping
7-
shape_names:
8-
- LayerList
97
resources:
108
Function:
119
fields:
@@ -19,6 +17,15 @@ resources:
1917
Code:
2018
compare:
2119
is_ignored: true
20+
Layers:
21+
set:
22+
- method: Create
23+
ignore: true
24+
LayerStatuses:
25+
is_read_only: true
26+
from:
27+
operation: GetFunction
28+
path: Configuration.Layers
2229
renames:
2330
operations:
2431
CreateFunction:
@@ -37,6 +44,8 @@ resources:
3744
template_path: hooks/function/sdk_read_one_post_set_output.go.tpl
3845
sdk_create_post_build_request:
3946
template_path: hooks/function/sdk_create_post_build_request.go.tpl
47+
sdk_create_post_set_output:
48+
template_path: hooks/function/sdk_create_post_set_output.go.tpl
4049
update_operation:
4150
custom_method_name: customUpdateFunction
4251
Alias:

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/lambda.services.k8s.aws_functions.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ spec:
122122
(KMS) key that's used to encrypt your function's environment variables.
123123
If it's not provided, Lambda uses a default service key.
124124
type: string
125+
layers:
126+
description: A list of function layers (https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html)
127+
to add to the function's execution environment. Specify each layer
128+
by its ARN, including the version.
129+
items:
130+
type: string
131+
type: array
125132
memorySize:
126133
description: The amount of memory available to the function (https://docs.aws.amazon.com/lambda/latest/dg/configuration-memory.html)
127134
at runtime. Increasing the function memory also increases its CPU
@@ -312,7 +319,7 @@ spec:
312319
description: The reason code for the last update that was performed
313320
on the function.
314321
type: string
315-
layers:
322+
layerStatuses:
316323
description: The function's layers (https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html).
317324
items:
318325
description: An Lambda layer (https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html).

generator.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ ignore:
44
# Alias
55
# CodeSigningConfig
66
# EventSourceMapping
7-
shape_names:
8-
- LayerList
97
resources:
108
Function:
119
fields:
@@ -19,6 +17,15 @@ resources:
1917
Code:
2018
compare:
2119
is_ignored: true
20+
Layers:
21+
set:
22+
- method: Create
23+
ignore: true
24+
LayerStatuses:
25+
is_read_only: true
26+
from:
27+
operation: GetFunction
28+
path: Configuration.Layers
2229
renames:
2330
operations:
2431
CreateFunction:
@@ -37,6 +44,8 @@ resources:
3744
template_path: hooks/function/sdk_read_one_post_set_output.go.tpl
3845
sdk_create_post_build_request:
3946
template_path: hooks/function/sdk_create_post_build_request.go.tpl
47+
sdk_create_post_set_output:
48+
template_path: hooks/function/sdk_create_post_set_output.go.tpl
4049
update_operation:
4150
custom_method_name: customUpdateFunction
4251
Alias:

helm/crds/lambda.services.k8s.aws_functions.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ spec:
122122
(KMS) key that's used to encrypt your function's environment variables.
123123
If it's not provided, Lambda uses a default service key.
124124
type: string
125+
layers:
126+
description: A list of function layers (https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html)
127+
to add to the function's execution environment. Specify each layer
128+
by its ARN, including the version.
129+
items:
130+
type: string
131+
type: array
125132
memorySize:
126133
description: The amount of memory available to the function (https://docs.aws.amazon.com/lambda/latest/dg/configuration-memory.html)
127134
at runtime. Increasing the function memory also increases its CPU
@@ -312,7 +319,7 @@ spec:
312319
description: The reason code for the last update that was performed
313320
on the function.
314321
type: string
315-
layers:
322+
layerStatuses:
316323
description: The function's layers (https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html).
317324
items:
318325
description: An Lambda layer (https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html).

pkg/resource/function/delta.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resource/function/sdk.go

Lines changed: 76 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
if resp.Layers != nil {
2+
f16 := []*svcapitypes.Layer{}
3+
for _, f16iter := range resp.Layers {
4+
f16elem := &svcapitypes.Layer{}
5+
if f16iter.Arn != nil {
6+
f16elem.ARN = f16iter.Arn
7+
}
8+
if f16iter.CodeSize != nil {
9+
f16elem.CodeSize = f16iter.CodeSize
10+
}
11+
if f16iter.SigningJobArn != nil {
12+
f16elem.SigningJobARN = f16iter.SigningJobArn
13+
}
14+
if f16iter.SigningProfileVersionArn != nil {
15+
f16elem.SigningProfileVersionARN = f16iter.SigningProfileVersionArn
16+
}
17+
f16 = append(f16, f16elem)
18+
}
19+
ko.Status.LayerStatuses = f16
20+
} else {
21+
ko.Status.LayerStatuses = nil
22+
}

0 commit comments

Comments
 (0)