Skip to content

Commit 8082723

Browse files
committed
revise
1 parent 85042fb commit 8082723

11 files changed

+55
-79
lines changed
+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2024-03-29T14:25:17Z"
3-
build_hash: e8df4d5a4b86dea0e227786c2c3d213e5aeda97a
4-
go_version: go1.22.0
5-
version: v0.33.0
6-
api_directory_checksum: c67645b15db39980ba51ff6303c34c5aafc55a9e
2+
build_date: "2024-04-08T23:27:24Z"
3+
build_hash: 37f4ba2b5a121a8786bc516e9ec4aa0b8b590c7d
4+
go_version: go1.21.6
5+
version: v0.33.0-1-g37f4ba2
6+
api_directory_checksum: 33a9d13c7343aec5c9acdc6e18fd2494f2af2e88
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.181
99
generator_config_info:
10-
file_checksum: d71df9c47727f5905a2be2ac8d5cfceff3c7bbec
10+
file_checksum: 3c1bc6e8df55e076b1a0a047af0b8a08f16832c2
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/function.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/generator.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ resources:
3636
- path: Status.State
3737
in: [ "Active" ]
3838
fields:
39-
Code.S3SHA256:
39+
Code.SHA256:
4040
type: string
4141
compare:
4242
is_ignored: true
43-
set:
44-
- method: Create
45-
ignore: true
43+
set:
44+
- ignore: "to"
45+
method: Create
4646
Code.S3Bucket:
4747
references:
4848
resource: Bucket

apis/v1alpha1/types.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/zz_generated.deepcopy.go

+7-2
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

+6-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ spec:
7070
type: string
7171
s3ObjectVersion:
7272
type: string
73-
s3SHA256:
73+
sha256:
7474
type: string
7575
zipFile:
7676
format: byte
@@ -267,6 +267,11 @@ spec:
267267
description: Set to true to publish the first version of the function
268268
during creation.
269269
type: boolean
270+
reservedConcurrentExecutions:
271+
description: The number of simultaneous executions to reserve for
272+
the function.
273+
format: int64
274+
type: integer
270275
role:
271276
description: The Amazon Resource Name (ARN) of the function's execution
272277
role.

generator.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ resources:
3636
- path: Status.State
3737
in: [ "Active" ]
3838
fields:
39-
Code.S3SHA256:
39+
Code.SHA256:
4040
type: string
4141
compare:
4242
is_ignored: true
43-
set:
44-
- method: Create
45-
ignore: true
43+
set:
44+
- ignore: "to"
45+
method: Create
4646
Code.S3Bucket:
4747
references:
4848
resource: Bucket

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ spec:
7070
type: string
7171
s3ObjectVersion:
7272
type: string
73-
s3SHA256:
73+
sha256:
7474
type: string
7575
zipFile:
7676
format: byte
@@ -267,6 +267,11 @@ spec:
267267
description: Set to true to publish the first version of the function
268268
during creation.
269269
type: boolean
270+
reservedConcurrentExecutions:
271+
description: The number of simultaneous executions to reserve for
272+
the function.
273+
format: int64
274+
type: integer
270275
role:
271276
description: The Amazon Resource Name (ARN) of the function's execution
272277
role.

pkg/resource/function/hooks.go

+18-56
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ func (rm *resourceManager) customUpdateFunction(
118118
"Spec.Tags",
119119
"Spec.ReservedConcurrentExecutions",
120120
"Spec.CodeSigningConfigARN",
121-
"Spec.Code.S3SHA256"):
121+
"Spec.Code.SHA256"):
122122
err = rm.updateFunctionConfiguration(ctx, desired, delta)
123123
if err != nil {
124124
return nil, err
125125
}
126-
case delta.DifferentAt("Spec.Code") || delta.DifferentAt("Spec.Code.S3SHA256"):
126+
case delta.DifferentAt("Spec.Code") || delta.DifferentAt("Spec.Code.SHA256"):
127127
err = rm.updateFunctionCode(ctx, desired, delta)
128128
if err != nil {
129129
return nil, err
@@ -400,7 +400,7 @@ func (rm *resourceManager) updateFunctionCode(
400400
}
401401

402402
if dspec.Code != nil {
403-
if delta.DifferentAt("Spec.Code.S3SHA256") && dspec.Code.S3SHA256 != nil {
403+
if delta.DifferentAt("Spec.Code.SHA256") && dspec.Code.SHA256 != nil {
404404
if dspec.PackageType != nil && *dspec.PackageType == "Image" {
405405
if delta.DifferentAt("Spec.Code.ImageURI") {
406406
if dspec.Code.ImageURI != nil {
@@ -429,22 +429,6 @@ func (rm *resourceManager) updateFunctionCode(
429429
}
430430
}
431431

432-
// if delta.DifferentAt("Spec.Code.ImageURI") {
433-
// if dspec.Code.ImageURI != nil {
434-
// input.ImageUri = aws.String(*dspec.Code.ImageURI)
435-
// }
436-
// } else if delta.DifferentAt("Spec.CodeS3SHA256") {
437-
// if dspec.Code.S3Key != nil {
438-
// input.S3Key = aws.String(*dspec.Code.S3Key)
439-
// }
440-
// if dspec.Code.S3Bucket != nil {
441-
// input.S3Bucket = aws.String(*dspec.Code.S3Bucket)
442-
// }
443-
// if dspec.Code.S3ObjectVersion != nil {
444-
// input.S3ObjectVersion = aws.String(*dspec.Code.S3ObjectVersion)
445-
// }
446-
// }
447-
448432
_, err = rm.sdkapi.UpdateFunctionCodeWithContext(ctx, input)
449433
rm.metrics.RecordAPICall("UPDATE", "UpdateFunctionCode", err)
450434
if err != nil {
@@ -500,22 +484,22 @@ func customPreCompare(
500484
delta.Add("Spec.Code.ImageURI", a.ko.Spec.Code.ImageURI, b.ko.Spec.Code.ImageURI)
501485
}
502486
}
503-
if a.ko.Spec.Code.S3SHA256 != nil {
504-
if ackcompare.HasNilDifference(a.ko.Spec.Code.S3SHA256, b.ko.Status.CodeSHA256) {
505-
delta.Add("Spec.Code.S3SHA256", a.ko.Spec.Code.S3SHA256, b.ko.Status.CodeSHA256)
506-
} else if a.ko.Spec.Code.S3SHA256 != nil && b.ko.Status.CodeSHA256 != nil {
507-
if *a.ko.Spec.Code.S3SHA256 != *b.ko.Status.CodeSHA256 {
508-
delta.Add("Spec.Code.S3SHA256", a.ko.Spec.Code.S3SHA256, b.ko.Status.CodeSHA256)
487+
if a.ko.Spec.Code.SHA256 != nil {
488+
if ackcompare.HasNilDifference(a.ko.Spec.Code.SHA256, b.ko.Status.CodeSHA256) {
489+
delta.Add("Spec.Code.SHA256", a.ko.Spec.Code.SHA256, b.ko.Status.CodeSHA256)
490+
} else if a.ko.Spec.Code.SHA256 != nil && b.ko.Status.CodeSHA256 != nil {
491+
if *a.ko.Spec.Code.SHA256 != *b.ko.Status.CodeSHA256 {
492+
delta.Add("Spec.Code.SHA256", a.ko.Spec.Code.SHA256, b.ko.Status.CodeSHA256)
509493
}
510494
}
511495
}
512496
} else if a.ko.Spec.PackageType != nil && *a.ko.Spec.PackageType == "Zip" {
513-
if a.ko.Spec.Code.S3SHA256 != nil {
514-
if ackcompare.HasNilDifference(a.ko.Spec.Code.S3SHA256, b.ko.Status.CodeSHA256) {
515-
delta.Add("Spec.Code.S3SHA256", a.ko.Spec.Code.S3SHA256, b.ko.Status.CodeSHA256)
516-
} else if a.ko.Spec.Code.S3SHA256 != nil && b.ko.Status.CodeSHA256 != nil {
517-
if *a.ko.Spec.Code.S3SHA256 != *b.ko.Status.CodeSHA256 {
518-
delta.Add("Spec.Code.S3SHA256", a.ko.Spec.Code.S3SHA256, b.ko.Status.CodeSHA256)
497+
if a.ko.Spec.Code.SHA256 != nil {
498+
if ackcompare.HasNilDifference(a.ko.Spec.Code.SHA256, b.ko.Status.CodeSHA256) {
499+
delta.Add("Spec.Code.SHA256", a.ko.Spec.Code.SHA256, b.ko.Status.CodeSHA256)
500+
} else if a.ko.Spec.Code.SHA256 != nil && b.ko.Status.CodeSHA256 != nil {
501+
if *a.ko.Spec.Code.SHA256 != *b.ko.Status.CodeSHA256 {
502+
delta.Add("Spec.Code.SHA256", a.ko.Spec.Code.SHA256, b.ko.Status.CodeSHA256)
519503
}
520504
}
521505
}
@@ -526,32 +510,10 @@ func customPreCompare(
526510
// and compares it with desired field values. Since the API doesn't return values of S3 fields, it doesn't
527511
// notice any changes between desired and latest, hence fails to recognize the update in the values.
528512

529-
// To solve this we created a new field 'Code.S3SHA256' to store the hash value of deployment package. Any change
513+
// To solve this we created a new field 'Code.SHA256' to store the hash value of deployment package. Any change
530514
// in hash value refers to change in S3 Key/Bucket/ObjectVersion and controller can recognize the change in
531-
// desired and latest value of 'Code.S3SHA256' and hence calls the update function.
532-
533-
//TODO(hialylmh) handle Spec.Code.S3bucket changes
534-
// if ackcompare.HasNilDifference(a.ko.Spec.Code.S3Bucket, b.ko.Spec.Code.S3Bucket) {
535-
// delta.Add("Spec.Code.S3Bucket", a.ko.Spec.Code.S3Bucket, b.ko.Spec.Code.S3Bucket)
536-
// } else if a.ko.Spec.Code.S3Bucket != nil && b.ko.Spec.Code.S3Bucket != nil {
537-
// if *a.ko.Spec.Code.S3Bucket != *b.ko.Spec.Code.S3Bucket {
538-
// delta.Add("Spec.Code.S3Bucket", a.ko.Spec.Code.S3Bucket, b.ko.Spec.Code.S3Bucket)
539-
// }
540-
// }
541-
// if ackcompare.HasNilDifference(a.ko.Spec.Code.S3Key, b.ko.Spec.Code.S3Key) {
542-
// delta.Add("Spec.Code.S3Key", a.ko.Spec.Code.S3Key, b.ko.Spec.Code.S3Key)
543-
// } else if a.ko.Spec.Code.S3Key != nil && b.ko.Spec.Code.S3Key != nil {
544-
// if *a.ko.Spec.Code.S3Key != *b.ko.Spec.Code.S3Key {
545-
// delta.Add("Spec.Code.S3Key", a.ko.Spec.Code.S3Key, b.ko.Spec.Code.S3Key)
546-
// }
547-
// }
548-
// if ackcompare.HasNilDifference(a.ko.Spec.Code.S3ObjectVersion, b.ko.Spec.Code.S3ObjectVersion) {
549-
// delta.Add("Spec.Code.S3ObjectVersion", a.ko.Spec.Code.S3ObjectVersion, b.ko.Spec.Code.S3ObjectVersion)
550-
// } else if a.ko.Spec.Code.S3ObjectVersion != nil && b.ko.Spec.Code.S3ObjectVersion != nil {
551-
// if *a.ko.Spec.Code.S3ObjectVersion != *b.ko.Spec.Code.S3ObjectVersion {
552-
// delta.Add("Spec.Code.S3ObjectVersion", a.ko.Spec.Code.S3ObjectVersion, b.ko.Spec.Code.S3ObjectVersion)
553-
// }
554-
// }
515+
// desired and latest value of 'Code.SHA256' and hence calls the update function.
516+
555517
}
556518
}
557519

pkg/resource/function/sdk.go

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/resources/function_code_s3.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ spec:
99
code:
1010
s3Bucket: $BUCKET_NAME
1111
s3Key: $LAMBDA_FILE_NAME
12-
s3SHA256: $HASH
12+
sha256: $HASH
1313
role: $LAMBDA_ROLE
1414
runtime: python3.9
1515
handler: main

0 commit comments

Comments
 (0)