Skip to content

Commit e0bcddb

Browse files
committed
Revert: emit unchanged SecretValueFromReference call; re-pin runtime
The runtime change reverted the SecretValueFromReference signature back to (ctx, ref) and restored the context-stash mechanism, so a breaking signature change is no longer forced on hand-written controller callers (e.g. rds-controller db_cluster/custom_update.go). Accordingly, revert the generated-code change: setSDKForSecret again emits rm.rr.SecretValueFromReference(ctx, <source>) with no resource-var threading, and the setSDKForContainer/Struct/Slice/Map/Union helpers drop the resourceVarName parameter. Re-pin the runtime replace directive to the amended fork commit (9bb3e73).
1 parent b93930b commit e0bcddb

5 files changed

Lines changed: 23 additions & 89 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ require (
104104
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
105105
)
106106

107-
replace github.com/aws-controllers-k8s/runtime => github.com/sapphirew/ack-runtime v0.0.0-20260607093755-4ee0bc56d816
107+
replace github.com/aws-controllers-k8s/runtime => github.com/sapphirew/ack-runtime v0.0.0-20260608212517-9bb3e738fe97

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
512512
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
513513
github.com/samber/lo v1.37.0 h1:XjVcB8g6tgUp8rsPsJ2CvhClfImrpL04YpQHXeHPhRw=
514514
github.com/samber/lo v1.37.0/go.mod h1:9vaz2O4o8oOnK23pd2TrXufcbdbJIa3b6cstBWKpopA=
515-
github.com/sapphirew/ack-runtime v0.0.0-20260607093755-4ee0bc56d816 h1:ZBmQHpcjrv+wmqublik4Mjf8jxG9W+gndnV5JpUU5v0=
516-
github.com/sapphirew/ack-runtime v0.0.0-20260607093755-4ee0bc56d816/go.mod h1:ljWD1IdtVx/qC7C4lVobF4vLNhno/xX5A78BOke1Ksk=
515+
github.com/sapphirew/ack-runtime v0.0.0-20260608212517-9bb3e738fe97 h1:l58zGokUaqMvnateGrtzKcGIrOSd7fnap+g+Cxeijd4=
516+
github.com/sapphirew/ack-runtime v0.0.0-20260608212517-9bb3e738fe97/go.mod h1:ljWD1IdtVx/qC7C4lVobF4vLNhno/xX5A78BOke1Ksk=
517517
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
518518
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
519519
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=

pkg/generate/ack/controller.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ var (
124124
return code.SetSDK(r.Config(), r, ackmodel.OpTypeDelete, sourceVarName, targetVarName, indentLevel)
125125
},
126126
"GoCodeSetSDKForStruct": func(r *ackmodel.CRD, targetFieldName string, targetVarName string, targetShapeRef *awssdkmodel.ShapeRef, sourceFieldPath string, sourceVarName string, indentLevel int) (string, error) {
127-
// Empty resourceVarName: SetSDKForStruct derives it from the
128-
// leading token of sourceVarName when invoked as an entry point.
129-
return code.SetSDKForStruct(r.Config(), r, "", targetFieldName, targetVarName, targetShapeRef, sourceFieldPath, sourceVarName, model.OpTypeList, indentLevel)
127+
return code.SetSDKForStruct(r.Config(), r, targetFieldName, targetVarName, targetShapeRef, sourceFieldPath, sourceVarName, model.OpTypeList, indentLevel)
130128
},
131129
"GoCodeSetResourceForStruct": func(r *ackmodel.CRD, targetFieldName string, targetVarName string, targetShapeRef *awssdkmodel.ShapeRef, sourceVarName string, sourceShapeRef *awssdkmodel.ShapeRef, indentLevel int) (string, error) {
132130
var setCfg *ackgenconfig.SetFieldConfig = nil

pkg/generate/code/set_sdk.go

Lines changed: 9 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,6 @@ func SetSDK(
119119
out := "\n"
120120
indent := strings.Repeat("\t", indentLevel)
121121

122-
// The owning resource variable, used so secret fields can pass it to the
123-
// runtime's SecretValueFromReference (which sets the cross-namespace
124-
// deprecation ACK.Advisory condition on it). It is the leading token of
125-
// the source variable path (e.g. "r" from "r.ko"); the generated
126-
// *resource type implements acktypes.ConditionManager.
127-
resourceVarName := sourceVarName
128-
if dot := strings.IndexByte(resourceVarName, '.'); dot != -1 {
129-
resourceVarName = resourceVarName[:dot]
130-
}
131-
132122
// Check if there's an input wrapper field path configured. If so, we need
133123
// to create a wrapper struct and populate its fields from the CRD spec,
134124
// then assign the wrapper to the input shape's wrapper field.
@@ -412,7 +402,6 @@ func SetSDK(
412402
)
413403
containerOut, err := setSDKForContainer(
414404
cfg, r,
415-
resourceVarName,
416405
memberName,
417406
memberVarName,
418407
sourceFieldPath,
@@ -441,7 +430,6 @@ func SetSDK(
441430
if r.IsSecretField(memberName) {
442431
out += setSDKForSecret(
443432
cfg, r,
444-
resourceVarName,
445433
memberName,
446434
targetVarName,
447435
sourceAdaptedVarName,
@@ -1017,10 +1005,6 @@ func setSDKReadMany(
10171005
func setSDKForContainer(
10181006
cfg *ackgenconfig.Config,
10191007
r *model.CRD,
1020-
// The name of the variable holding the owning resource (a *resource,
1021-
// which implements acktypes.ConditionManager). Threaded down so secret
1022-
// fields nested in collections can pass it to SecretValueFromReference.
1023-
resourceVarName string,
10241008
// The name of the SDK Input shape member we're outputting for
10251009
targetFieldName string,
10261010
// The variable name that we want to set a value to
@@ -1039,7 +1023,6 @@ func setSDKForContainer(
10391023
case "structure":
10401024
return SetSDKForStruct(
10411025
cfg, r,
1042-
resourceVarName,
10431026
targetFieldName,
10441027
targetVarName,
10451028
targetShapeRef,
@@ -1051,7 +1034,6 @@ func setSDKForContainer(
10511034
case "list":
10521035
return setSDKForSlice(
10531036
cfg, r,
1054-
resourceVarName,
10551037
targetFieldName,
10561038
targetVarName,
10571039
targetShapeRef,
@@ -1063,7 +1045,6 @@ func setSDKForContainer(
10631045
case "map":
10641046
return setSDKForMap(
10651047
cfg, r,
1066-
resourceVarName,
10671048
targetFieldName,
10681049
targetVarName,
10691050
targetShapeRef,
@@ -1075,7 +1056,6 @@ func setSDKForContainer(
10751056
case "union":
10761057
return setSDKForUnion(
10771058
cfg, r,
1078-
resourceVarName,
10791059
targetFieldName,
10801060
targetVarName,
10811061
targetShapeRef,
@@ -1094,7 +1074,6 @@ func setSDKForContainer(
10941074
)
10951075
out += setSDKForSecret(
10961076
cfg, r,
1097-
resourceVarName,
10981077
"",
10991078
targetVarName,
11001079
sourceVarName,
@@ -1122,17 +1101,14 @@ func setSDKForContainer(
11221101
// the value of a Secret when the type of the source variable is a
11231102
// SecretKeyReference.
11241103
//
1125-
// Cross-namespace validation (and the Phase 1 deprecation notice) is performed
1126-
// inside the runtime's SecretValueFromReference, so it is not emitted here.
1127-
// This ensures every caller is covered, including custom update functions and
1128-
// hooks that call SecretValueFromReference directly. The owning resource is
1129-
// passed as the second argument so the runtime can set the cross-namespace
1130-
// deprecation ACK.Advisory condition on it; it is derived from the source
1131-
// variable (e.g. "r" from "r.ko.Spec.MasterUserPassword").
1104+
// Cross-namespace validation (and the Phase 1 deprecation warning) is
1105+
// performed inside the runtime's SecretValueFromReference, so it is not
1106+
// emitted here. This ensures every caller is covered, including custom
1107+
// update functions and hooks that call SecretValueFromReference directly.
11321108
//
11331109
// The Go code output from this function looks like this:
11341110
//
1135-
// tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, r.ko.Spec.MasterUserPassword)
1111+
// tmpSecret, err := rm.rr.SecretValueFromReference(ctx, ko.Spec.MasterUserPassword)
11361112
// if err != nil {
11371113
// return nil, ackrequeue.Needed(err)
11381114
// }
@@ -1146,11 +1122,6 @@ func setSDKForContainer(
11461122
func setSDKForSecret(
11471123
cfg *ackgenconfig.Config,
11481124
r *model.CRD,
1149-
// The name of the variable holding the owning resource (a
1150-
// *resource, which implements acktypes.ConditionManager). It is passed to
1151-
// SecretValueFromReference so the runtime can set the cross-namespace
1152-
// deprecation ACK.Advisory condition on it. Typically "r" or "desired".
1153-
resourceVarName string,
11541125
// The name of the SDK Shape field we're setting
11551126
targetFieldName string,
11561127
// The variable name that we want to set a value on
@@ -1167,14 +1138,12 @@ func setSDKForSecret(
11671138
// Cross-namespace validation for the secret reference is performed inside
11681139
// the runtime's SecretValueFromReference, so that every call site is
11691140
// covered (including custom update functions and hooks). No per-call
1170-
// validation is generated here. The owning resource is passed so the
1171-
// runtime can set the cross-namespace deprecation ACK.Advisory condition
1172-
// on it.
1141+
// validation is generated here.
11731142

1174-
// tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, r.ko.Spec.MasterUserPassword)
1143+
// tmpSecret, err := rm.rr.SecretValueFromReference(ctx, ko.Spec.MasterUserPassword)
11751144
out += fmt.Sprintf(
1176-
"%s\t%s, err := rm.rr.SecretValueFromReference(ctx, %s, %s)\n",
1177-
indent, secVar, resourceVarName, sourceVarName,
1145+
"%s\t%s, err := rm.rr.SecretValueFromReference(ctx, %s)\n",
1146+
indent, secVar, sourceVarName,
11781147
)
11791148
// if err != nil {
11801149
// return nil, ackrequeue.Needed(err)
@@ -1206,12 +1175,6 @@ func setSDKForSecret(
12061175
func SetSDKForStruct(
12071176
cfg *ackgenconfig.Config,
12081177
r *model.CRD,
1209-
// The name of the variable holding the owning resource (a *resource,
1210-
// which implements acktypes.ConditionManager). Threaded down so secret
1211-
// fields nested in this struct can pass it to SecretValueFromReference.
1212-
// When this is the entry point (e.g. the GoCodeSetSDKForStruct template
1213-
// helper), it is derived from the leading token of sourceVarName.
1214-
resourceVarName string,
12151178
// The name of the CR field we're outputting for
12161179
targetFieldName string,
12171180
// The variable name that we want to set a value to
@@ -1228,16 +1191,6 @@ func SetSDKForStruct(
12281191
out := ""
12291192
indent := strings.Repeat("\t", indentLevel)
12301193
targetShape := targetShapeRef.Shape
1231-
// When SetSDKForStruct is invoked as a top-level entry point (rather than
1232-
// recursively via setSDKForContainer), resourceVarName is not supplied by
1233-
// the caller. Fall back to the leading token of the source variable path
1234-
// (e.g. "r" from "r.ko.Spec.Foo"), which names the owning *resource.
1235-
if resourceVarName == "" {
1236-
resourceVarName = sourceVarName
1237-
if dot := strings.IndexByte(resourceVarName, '.'); dot != -1 {
1238-
resourceVarName = resourceVarName[:dot]
1239-
}
1240-
}
12411194

12421195
for memberIndex, memberName := range targetShape.MemberNames() {
12431196
memberShapeRef := targetShape.MemberRefs[memberName]
@@ -1295,7 +1248,6 @@ func SetSDKForStruct(
12951248
)
12961249
containerOut, err := setSDKForContainer(
12971250
cfg, r,
1298-
resourceVarName,
12991251
memberName,
13001252
memberVarName,
13011253
memberFieldPath,
@@ -1324,7 +1276,6 @@ func SetSDKForStruct(
13241276
if r.IsSecretField(memberFieldPath) {
13251277
out += setSDKForSecret(
13261278
cfg, r,
1327-
resourceVarName,
13281279
memberName,
13291280
targetVarName,
13301281
sourceAdaptedVarName,
@@ -1359,10 +1310,6 @@ func SetSDKForStruct(
13591310
func setSDKForSlice(
13601311
cfg *ackgenconfig.Config,
13611312
r *model.CRD,
1362-
// The name of the variable holding the owning resource (a *resource,
1363-
// which implements acktypes.ConditionManager). Threaded down so secret
1364-
// fields nested in this slice can pass it to SecretValueFromReference.
1365-
resourceVarName string,
13661313
// The name of the CR field we're outputting for
13671314
targetFieldName string,
13681315
// The variable name that we want to set a value to
@@ -1435,7 +1382,6 @@ func setSDKForSlice(
14351382
} else {
14361383
containerOut, err := setSDKForContainer(
14371384
cfg, r,
1438-
resourceVarName,
14391385
containerFieldName,
14401386
elemVarName,
14411387
sourceFieldPath,
@@ -1468,10 +1414,6 @@ func setSDKForSlice(
14681414
func setSDKForMap(
14691415
cfg *ackgenconfig.Config,
14701416
r *model.CRD,
1471-
// The name of the variable holding the owning resource (a *resource,
1472-
// which implements acktypes.ConditionManager). Threaded down so secret
1473-
// fields nested in this map can pass it to SecretValueFromReference.
1474-
resourceVarName string,
14751417
// The name of the CR field we're outputting for
14761418
targetFieldName string,
14771419
// The variable name that we want to set a value to
@@ -1539,7 +1481,6 @@ func setSDKForMap(
15391481
} else {
15401482
containerOut, err := setSDKForContainer(
15411483
cfg, r,
1542-
resourceVarName,
15431484
containerFieldName,
15441485
valVarName,
15451486
sourceFieldPath,
@@ -1903,10 +1844,6 @@ func resolveAWSMapValueType(valueType string) string {
19031844
func setSDKForUnion(
19041845
cfg *ackgenconfig.Config,
19051846
r *model.CRD,
1906-
// The name of the variable holding the owning resource (a *resource,
1907-
// which implements acktypes.ConditionManager). Threaded down so secret
1908-
// fields nested in this union can pass it to SecretValueFromReference.
1909-
resourceVarName string,
19101847
// The name of the CR field we're outputting for
19111848
targetFieldName string,
19121849
// The variable name that we want to set a value to
@@ -1992,7 +1929,6 @@ func setSDKForUnion(
19921929
)
19931930
containerOut, err := setSDKForContainer(
19941931
cfg, r,
1995-
resourceVarName,
19961932
memberName,
19971933
indexedVarName,
19981934
memberFieldPath,

pkg/generate/code/set_sdk_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func TestSetSDK_MemoryDB_User_Create(t *testing.T) {
105105
for _, f1f0iter := range r.ko.Spec.AuthenticationMode.Passwords {
106106
var f1f0elem string
107107
if f1f0iter != nil {
108-
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, f1f0iter)
108+
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, f1f0iter)
109109
if err != nil {
110110
return nil, ackrequeue.Needed(err)
111111
}
@@ -208,7 +208,7 @@ func TestSetSDK_OpenSearch_Domain_Create(t *testing.T) {
208208
f3f4.MasterUserName = r.ko.Spec.AdvancedSecurityOptions.MasterUserOptions.MasterUserName
209209
}
210210
if r.ko.Spec.AdvancedSecurityOptions.MasterUserOptions.MasterUserPassword != nil {
211-
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, r.ko.Spec.AdvancedSecurityOptions.MasterUserOptions.MasterUserPassword)
211+
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r.ko.Spec.AdvancedSecurityOptions.MasterUserOptions.MasterUserPassword)
212212
if err != nil {
213213
return nil, ackrequeue.Needed(err)
214214
}
@@ -841,7 +841,7 @@ func TestSetSDK_ECR_Repository_Create(t *testing.T) {
841841
// res.SetAtRestEncryptionEnabled(*r.ko.Spec.AtRestEncryptionEnabled)
842842
// }
843843
// if r.ko.Spec.AuthToken != nil {
844-
// tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, r.ko.Spec.AuthToken)
844+
// tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r.ko.Spec.AuthToken)
845845
// if err != nil {
846846
// return nil, ackrequeue.Needed(err)
847847
// }
@@ -1096,7 +1096,7 @@ func TestSetSDK_ECR_Repository_Create(t *testing.T) {
10961096
// expected := `
10971097
// res.SetApplyImmediately(true)
10981098
// if r.ko.Spec.AuthToken != nil {
1099-
// tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, r.ko.Spec.AuthToken)
1099+
// tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r.ko.Spec.AuthToken)
11001100
// if err != nil {
11011101
// return nil, ackrequeue.Needed(err)
11021102
// }
@@ -1218,7 +1218,7 @@ func TestSetSDK_ECR_Repository_Create(t *testing.T) {
12181218
// for _, f3iter := range r.ko.Spec.Passwords {
12191219
// var f3elem string
12201220
// if f3iter != nil {
1221-
// tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, f3iter)
1221+
// tmpSecret, err := rm.rr.SecretValueFromReference(ctx, f3iter)
12221222
// if err != nil {
12231223
// return nil, ackrequeue.Needed(err)
12241224
// }
@@ -1489,7 +1489,7 @@ func TestSetSDK_RDS_DBInstance_Create(t *testing.T) {
14891489
res.ManageMasterUserPassword = r.ko.Spec.ManageMasterUserPassword
14901490
}
14911491
if r.ko.Spec.MasterUserPassword != nil {
1492-
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, r.ko.Spec.MasterUserPassword)
1492+
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r.ko.Spec.MasterUserPassword)
14931493
if err != nil {
14941494
return nil, ackrequeue.Needed(err)
14951495
}
@@ -1779,7 +1779,7 @@ func TestSetSDK_RDS_DBInstance_Update(t *testing.T) {
17791779
}
17801780
if delta.DifferentAt("Spec.MasterUserPassword") {
17811781
if r.ko.Spec.MasterUserPassword != nil {
1782-
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, r.ko.Spec.MasterUserPassword)
1782+
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r.ko.Spec.MasterUserPassword)
17831783
if err != nil {
17841784
return nil, ackrequeue.Needed(err)
17851785
}
@@ -2318,7 +2318,7 @@ func TestSetSDK_MQ_Broker_Create(t *testing.T) {
23182318
f18elem.Groups = aws.ToStringSlice(f18iter.Groups)
23192319
}
23202320
if f18iter.Password != nil {
2321-
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, f18iter.Password)
2321+
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, f18iter.Password)
23222322
if err != nil {
23232323
return nil, ackrequeue.Needed(err)
23242324
}
@@ -4669,7 +4669,7 @@ func TestSetSDK_Lambda_Function_EnvironmentVariable_MapOfSecrets_Create(t *testi
46694669
for f4f0key, f4f0valiter := range r.ko.Spec.Environment.Variables {
46704670
var f4f0val string
46714671
if f4f0valiter != nil {
4672-
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, f4f0valiter)
4672+
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, f4f0valiter)
46734673
if err != nil {
46744674
return nil, ackrequeue.Needed(err)
46754675
}
@@ -4806,7 +4806,7 @@ func TestSetSDK_Lambda_Function_EnvironmentVariable_MapOfSecrets_Update(t *testi
48064806
for f2f0key, f2f0valiter := range r.ko.Spec.Environment.Variables {
48074807
var f2f0val string
48084808
if f2f0valiter != nil {
4809-
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, r, f2f0valiter)
4809+
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, f2f0valiter)
48104810
if err != nil {
48114811
return nil, ackrequeue.Needed(err)
48124812
}

0 commit comments

Comments
 (0)