Skip to content

Commit 3bae07c

Browse files
authored
Update to controller-gen v0.7.0 (#202)
Issue #, if available: aws-controllers-k8s/community#951 Description of changes: * Use latest controller-gen release, which unblocks aws-sdk-go upgrade for apigatewayv2 controller * do not restrict map value type when using `reflect.DeepEqual` method By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 1ae7e2b commit 3bae07c

File tree

3 files changed

+101
-4
lines changed

3 files changed

+101
-4
lines changed

pkg/generate/code/compare.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ func compareMap(
403403
"%sif !ackcompare.MapStringStringPEqual(%s, %s) {\n",
404404
indent, firstResVarName, secondResVarName,
405405
)
406-
case "structure":
406+
default:
407407
// NOTE(jaypipes): Using reflect here is really punting. We should
408408
// implement this in a cleaner, more efficient fashion by walking the
409409
// keys and struct values and comparing each struct individually,
@@ -413,8 +413,6 @@ func compareMap(
413413
"%sif !reflect.DeepEqual(%s, %s) {\n",
414414
indent, firstResVarName, secondResVarName,
415415
)
416-
default:
417-
panic("Unsupported shape type in generate.code.compareMap: " + shape.Type)
418416
}
419417
// delta.Add("Spec.Name", a.ko.Spec.Name, b.ko.Spec.Name)
420418
out += fmt.Sprintf(

pkg/generate/code/compare_test.go

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,102 @@ func TestCompareResource_Lambda_Function(t *testing.T) {
376376
),
377377
)
378378
}
379+
380+
func TestCompareResource_APIGatewayv2_Route(t *testing.T) {
381+
assert := assert.New(t)
382+
require := require.New(t)
383+
384+
g := testutil.NewModelForService(t, "apigatewayv2")
385+
386+
crd := testutil.GetCRDByName(t, g, "Route")
387+
require.NotNil(crd)
388+
389+
expected := `
390+
if ackcompare.HasNilDifference(a.ko.Spec.APIID, b.ko.Spec.APIID) {
391+
delta.Add("Spec.APIID", a.ko.Spec.APIID, b.ko.Spec.APIID)
392+
} else if a.ko.Spec.APIID != nil && b.ko.Spec.APIID != nil {
393+
if *a.ko.Spec.APIID != *b.ko.Spec.APIID {
394+
delta.Add("Spec.APIID", a.ko.Spec.APIID, b.ko.Spec.APIID)
395+
}
396+
}
397+
if ackcompare.HasNilDifference(a.ko.Spec.APIKeyRequired, b.ko.Spec.APIKeyRequired) {
398+
delta.Add("Spec.APIKeyRequired", a.ko.Spec.APIKeyRequired, b.ko.Spec.APIKeyRequired)
399+
} else if a.ko.Spec.APIKeyRequired != nil && b.ko.Spec.APIKeyRequired != nil {
400+
if *a.ko.Spec.APIKeyRequired != *b.ko.Spec.APIKeyRequired {
401+
delta.Add("Spec.APIKeyRequired", a.ko.Spec.APIKeyRequired, b.ko.Spec.APIKeyRequired)
402+
}
403+
}
404+
if !ackcompare.SliceStringPEqual(a.ko.Spec.AuthorizationScopes, b.ko.Spec.AuthorizationScopes) {
405+
delta.Add("Spec.AuthorizationScopes", a.ko.Spec.AuthorizationScopes, b.ko.Spec.AuthorizationScopes)
406+
}
407+
if ackcompare.HasNilDifference(a.ko.Spec.AuthorizationType, b.ko.Spec.AuthorizationType) {
408+
delta.Add("Spec.AuthorizationType", a.ko.Spec.AuthorizationType, b.ko.Spec.AuthorizationType)
409+
} else if a.ko.Spec.AuthorizationType != nil && b.ko.Spec.AuthorizationType != nil {
410+
if *a.ko.Spec.AuthorizationType != *b.ko.Spec.AuthorizationType {
411+
delta.Add("Spec.AuthorizationType", a.ko.Spec.AuthorizationType, b.ko.Spec.AuthorizationType)
412+
}
413+
}
414+
if ackcompare.HasNilDifference(a.ko.Spec.AuthorizerID, b.ko.Spec.AuthorizerID) {
415+
delta.Add("Spec.AuthorizerID", a.ko.Spec.AuthorizerID, b.ko.Spec.AuthorizerID)
416+
} else if a.ko.Spec.AuthorizerID != nil && b.ko.Spec.AuthorizerID != nil {
417+
if *a.ko.Spec.AuthorizerID != *b.ko.Spec.AuthorizerID {
418+
delta.Add("Spec.AuthorizerID", a.ko.Spec.AuthorizerID, b.ko.Spec.AuthorizerID)
419+
}
420+
}
421+
if ackcompare.HasNilDifference(a.ko.Spec.ModelSelectionExpression, b.ko.Spec.ModelSelectionExpression) {
422+
delta.Add("Spec.ModelSelectionExpression", a.ko.Spec.ModelSelectionExpression, b.ko.Spec.ModelSelectionExpression)
423+
} else if a.ko.Spec.ModelSelectionExpression != nil && b.ko.Spec.ModelSelectionExpression != nil {
424+
if *a.ko.Spec.ModelSelectionExpression != *b.ko.Spec.ModelSelectionExpression {
425+
delta.Add("Spec.ModelSelectionExpression", a.ko.Spec.ModelSelectionExpression, b.ko.Spec.ModelSelectionExpression)
426+
}
427+
}
428+
if ackcompare.HasNilDifference(a.ko.Spec.OperationName, b.ko.Spec.OperationName) {
429+
delta.Add("Spec.OperationName", a.ko.Spec.OperationName, b.ko.Spec.OperationName)
430+
} else if a.ko.Spec.OperationName != nil && b.ko.Spec.OperationName != nil {
431+
if *a.ko.Spec.OperationName != *b.ko.Spec.OperationName {
432+
delta.Add("Spec.OperationName", a.ko.Spec.OperationName, b.ko.Spec.OperationName)
433+
}
434+
}
435+
if ackcompare.HasNilDifference(a.ko.Spec.RequestModels, b.ko.Spec.RequestModels) {
436+
delta.Add("Spec.RequestModels", a.ko.Spec.RequestModels, b.ko.Spec.RequestModels)
437+
} else if a.ko.Spec.RequestModels != nil && b.ko.Spec.RequestModels != nil {
438+
if !ackcompare.MapStringStringPEqual(a.ko.Spec.RequestModels, b.ko.Spec.RequestModels) {
439+
delta.Add("Spec.RequestModels", a.ko.Spec.RequestModels, b.ko.Spec.RequestModels)
440+
}
441+
}
442+
if ackcompare.HasNilDifference(a.ko.Spec.RequestParameters, b.ko.Spec.RequestParameters) {
443+
delta.Add("Spec.RequestParameters", a.ko.Spec.RequestParameters, b.ko.Spec.RequestParameters)
444+
} else if a.ko.Spec.RequestParameters != nil && b.ko.Spec.RequestParameters != nil {
445+
if !reflect.DeepEqual(a.ko.Spec.RequestParameters, b.ko.Spec.RequestParameters) {
446+
delta.Add("Spec.RequestParameters", a.ko.Spec.RequestParameters, b.ko.Spec.RequestParameters)
447+
}
448+
}
449+
if ackcompare.HasNilDifference(a.ko.Spec.RouteKey, b.ko.Spec.RouteKey) {
450+
delta.Add("Spec.RouteKey", a.ko.Spec.RouteKey, b.ko.Spec.RouteKey)
451+
} else if a.ko.Spec.RouteKey != nil && b.ko.Spec.RouteKey != nil {
452+
if *a.ko.Spec.RouteKey != *b.ko.Spec.RouteKey {
453+
delta.Add("Spec.RouteKey", a.ko.Spec.RouteKey, b.ko.Spec.RouteKey)
454+
}
455+
}
456+
if ackcompare.HasNilDifference(a.ko.Spec.RouteResponseSelectionExpression, b.ko.Spec.RouteResponseSelectionExpression) {
457+
delta.Add("Spec.RouteResponseSelectionExpression", a.ko.Spec.RouteResponseSelectionExpression, b.ko.Spec.RouteResponseSelectionExpression)
458+
} else if a.ko.Spec.RouteResponseSelectionExpression != nil && b.ko.Spec.RouteResponseSelectionExpression != nil {
459+
if *a.ko.Spec.RouteResponseSelectionExpression != *b.ko.Spec.RouteResponseSelectionExpression {
460+
delta.Add("Spec.RouteResponseSelectionExpression", a.ko.Spec.RouteResponseSelectionExpression, b.ko.Spec.RouteResponseSelectionExpression)
461+
}
462+
}
463+
if ackcompare.HasNilDifference(a.ko.Spec.Target, b.ko.Spec.Target) {
464+
delta.Add("Spec.Target", a.ko.Spec.Target, b.ko.Spec.Target)
465+
} else if a.ko.Spec.Target != nil && b.ko.Spec.Target != nil {
466+
if *a.ko.Spec.Target != *b.ko.Spec.Target {
467+
delta.Add("Spec.Target", a.ko.Spec.Target, b.ko.Spec.Target)
468+
}
469+
}
470+
`
471+
assert.Equal(
472+
expected,
473+
code.CompareResource(
474+
crd.Config(), crd, "delta", "a.ko", "b.ko", 1,
475+
),
476+
)
477+
}

scripts/lib/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
CONTROLLER_TOOLS_VERSION="v0.6.1"
3+
CONTROLLER_TOOLS_VERSION="v0.7.0"
44

55
# setting the -x option if debugging is true
66
if [[ "${DEBUG:-"false"}" = "true" ]]; then

0 commit comments

Comments
 (0)