Skip to content

Commit 18a2a64

Browse files
authored
Remove performSpecUpdate(boolean) from Set<Operation>Output. (#132)
Issue #, if available: aws-controllers-k8s/community#812 Description of changes: * Do not restrict Create and Update operation output to only updating the Status of latest k8s resource. This change will allow both Spec and Status of latest object to be updated. * Removing of conditional "performSpecUpdate" will allow both Spec and Status fields to be updated. * This will allow server-side-defaults to be populated into the k8s latest object. Server-side-defaults are the default values added by AWS service upon resource creation/update when these optional values were not specified by the user. ------ make test ``` ➜ code-generator git:(allow-spec-updates) make test go test -tags codegen ./... ? github.com/aws-controllers-k8s/code-generator/cmd/ack-generate [no test files] ? github.com/aws-controllers-k8s/code-generator/cmd/ack-generate/command [no test files] ok github.com/aws-controllers-k8s/code-generator/pkg/generate/ack (cached) ok github.com/aws-controllers-k8s/code-generator/pkg/generate/code (cached) ? github.com/aws-controllers-k8s/code-generator/pkg/generate/config [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/generate/crossplane [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/generate/olm [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/generate/templateset [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/metadata [no test files] ok github.com/aws-controllers-k8s/code-generator/pkg/model (cached) ok github.com/aws-controllers-k8s/code-generator/pkg/model/multiversion (cached) ok github.com/aws-controllers-k8s/code-generator/pkg/names (cached) ? github.com/aws-controllers-k8s/code-generator/pkg/testutil [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/util [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/version [no test files] ``` make build-controller ``` ➜ code-generator git:(allow-spec-updates) make build-controller building ack-generate ... ok. Copying common custom resource definitions into ecr Building Kubernetes API objects for ecr Generating deepcopy code for ecr Generating custom resource definitions for ecr Building service controller for ecr Generating RBAC manifests for ecr Running gofmt against generated code for ecr ``` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent a5d6be1 commit 18a2a64

11 files changed

+391
-44
lines changed

pkg/generate/ack/controller.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ var (
5757
"GoCodeSetExceptionMessageCheck": func(r *ackmodel.CRD, httpStatusCode int) string {
5858
return code.CheckExceptionMessage(r.Config(), r, httpStatusCode)
5959
},
60-
"GoCodeSetReadOneOutput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int, performSpecUpdate bool) string {
61-
return code.SetResource(r.Config(), r, ackmodel.OpTypeGet, sourceVarName, targetVarName, indentLevel, performSpecUpdate)
60+
"GoCodeSetReadOneOutput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int) string {
61+
return code.SetResource(r.Config(), r, ackmodel.OpTypeGet, sourceVarName, targetVarName, indentLevel)
6262
},
6363
"GoCodeSetReadOneInput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int) string {
6464
return code.SetSDK(r.Config(), r, ackmodel.OpTypeGet, sourceVarName, targetVarName, indentLevel)
6565
},
66-
"GoCodeSetReadManyOutput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int, performSpecUpdate bool) string {
67-
return code.SetResource(r.Config(), r, ackmodel.OpTypeList, sourceVarName, targetVarName, indentLevel, performSpecUpdate)
66+
"GoCodeSetReadManyOutput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int) string {
67+
return code.SetResource(r.Config(), r, ackmodel.OpTypeList, sourceVarName, targetVarName, indentLevel)
6868
},
6969
"GoCodeSetReadManyInput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int) string {
7070
return code.SetSDK(r.Config(), r, ackmodel.OpTypeList, sourceVarName, targetVarName, indentLevel)
@@ -78,14 +78,14 @@ var (
7878
"GoCodeGetAttributesSetOutput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int) string {
7979
return code.SetResourceGetAttributes(r.Config(), r, sourceVarName, targetVarName, indentLevel)
8080
},
81-
"GoCodeSetCreateOutput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int, performSpecUpdate bool) string {
82-
return code.SetResource(r.Config(), r, ackmodel.OpTypeCreate, sourceVarName, targetVarName, indentLevel, performSpecUpdate)
81+
"GoCodeSetCreateOutput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int) string {
82+
return code.SetResource(r.Config(), r, ackmodel.OpTypeCreate, sourceVarName, targetVarName, indentLevel)
8383
},
8484
"GoCodeSetCreateInput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int) string {
8585
return code.SetSDK(r.Config(), r, ackmodel.OpTypeCreate, sourceVarName, targetVarName, indentLevel)
8686
},
87-
"GoCodeSetUpdateOutput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int, performSpecUpdate bool) string {
88-
return code.SetResource(r.Config(), r, ackmodel.OpTypeUpdate, sourceVarName, targetVarName, indentLevel, performSpecUpdate)
87+
"GoCodeSetUpdateOutput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int) string {
88+
return code.SetResource(r.Config(), r, ackmodel.OpTypeUpdate, sourceVarName, targetVarName, indentLevel)
8989
},
9090
"GoCodeSetUpdateInput": func(r *ackmodel.CRD, sourceVarName string, targetVarName string, indentLevel int) string {
9191
return code.SetSDK(r.Config(), r, ackmodel.OpTypeUpdate, sourceVarName, targetVarName, indentLevel)

pkg/generate/code/set_resource.go

-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828

2929
// SetResource returns the Go code that sets a CRD's field value to the value
3030
// of an output shape's member fields. Status fields are always updated.
31-
// Update of Spec fields depends on 'performSpecUpdate' parameter
3231
//
3332
// Assume a CRD called Repository that looks like this pseudo-schema:
3433
//
@@ -89,8 +88,6 @@ func SetResource(
8988
targetVarName string,
9089
// Number of levels of indentation to use
9190
indentLevel int,
92-
// boolean to indicate whether Spec fields should be updated from opTypeOutput
93-
performSpecUpdate bool,
9491
) string {
9592
var op *awssdkmodel.Operation
9693
switch opType {
@@ -220,9 +217,6 @@ func SetResource(
220217
f, found = r.SpecFields[renamedName]
221218
if found {
222219
targetAdaptedVarName += cfg.PrefixConfig.SpecField
223-
if !performSpecUpdate {
224-
continue
225-
}
226220
} else {
227221
f, found = r.StatusFields[memberName]
228222
if !found {

0 commit comments

Comments
 (0)