Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Spec field length #310

Merged
merged 1 commit into from
Apr 5, 2022
Merged

Fix Spec field length #310

merged 1 commit into from
Apr 5, 2022

Conversation

nmvk
Copy link
Member

@nmvk nmvk commented Mar 21, 2022

Updated to trim the prefix "." to calculate the length of the Spec.

cfg.PrefixConfig.SpecField value is .Spec so old code len(cfg.PrefixConfig.SpecField) + 1 constructed incorrect field path and ignored the config set in generator.yaml

Added unit test to validate that below block is not generated.

if !ackcompare.SliceStringPEqual(a.ko.Spec.AuthenticationMode.Passwords, b.ko.Spec.AuthenticationMode.Passwords) {
	delta.Add("Spec.AuthenticationMode.Passwords", a.ko.Spec.AuthenticationMode.Passwords, b.ko.Spec.AuthenticationMode.Passwords)
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -564,7 +564,8 @@ func CompareStruct(
var compareConfig *ackgenconfig.CompareFieldConfig
// memberFieldPath contains the field path along with the prefix cfg.PrefixConfig.SpecField + "." hence we
// would need to substring to exclude cfg.PrefixConfig.SpecField + "." to get correct field config.
fieldConfig := fieldConfigs[memberFieldPath[len(cfg.PrefixConfig.SpecField) + 1 :len(memberFieldPath)]]
specFieldLen := len(strings.TrimPrefix(cfg.PrefixConfig.SpecField, "."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix makes sense, i still wonder what part of elasticache/memorydb delta generated code was broken? can we add some unit tests? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new unit test :)

@RedbackThomson
Copy link
Contributor

Echoing @a-hilaly here - Please update the PR to include an issue describing the bug this is fixing, or describe the error directly in the PR body. I don't have any context for what this line of code is doing, or should be doing.

Updated to trim the prefix "." to calculate the
length.
@vijtrip2
Copy link
Contributor

vijtrip2 commented Apr 5, 2022

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 5, 2022
@ack-bot
Copy link
Collaborator

ack-bot commented Apr 5, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nmvk, vijtrip2

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-bot ack-bot merged commit 4bbc4f1 into aws-controllers-k8s:main Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants