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

Add utility functions for supporting CloudFormation CustomResources #1808

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

flostadler
Copy link
Contributor

@flostadler flostadler commented Nov 7, 2024

This change adds utility methods needed for supporting CloudFormation custom resources.

The main part of this change is a method for deeply converting all primitive values in a map[string]interface{} to strings. This is needed because CloudFormation has this behavior: aws-cloudformation/cloudformation-coverage-roadmap#1037

@flostadler
Copy link
Contributor Author

flostadler commented Nov 7, 2024

Copy link
Contributor

github-actions bot commented Nov 7, 2024

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 92.50000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 46.78%. Comparing base (eafde1c) to head (4cd4ddb).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
provider/pkg/naming/convert.go 90.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1808      +/-   ##
==========================================
+ Coverage   46.51%   46.78%   +0.27%     
==========================================
  Files          42       42              
  Lines        6127     6164      +37     
==========================================
+ Hits         2850     2884      +34     
- Misses       3050     3052       +2     
- Partials      227      228       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@flostadler flostadler requested review from t0yv0, corymhall and a team November 7, 2024 17:51
@flostadler flostadler self-assigned this Nov 7, 2024
@flostadler flostadler marked this pull request as ready for review November 7, 2024 17:51
switch reflect.TypeOf(value).Kind() {
case reflect.Map:
valueMap, ok := value.(map[string]interface{})
if !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

Under what circumstance would this happen (!ok)? Should we throw an error here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case it shouldn't happen because CloudFormation only supports strings as keys.

Throwing sounds more apt in this case. Will change it accordingly!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually ended up changing the implementation to allow arbitrary map keys. That way the method is cleaner and we don't need to worry about somebody using it in the future for another usecase and tripping over it only supporting string-indexed maps

if !ok {
return value
}
result := map[string]interface{}{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just call ToStringifiedMap instead to avoid duplicating the code?

Base automatically changed from flostadler/cfn-custom-resource-aws-clients to master November 8, 2024 11:58
@flostadler flostadler force-pushed the flostadler/cfn-custom-resource-helpers branch from 60b5047 to 4cd4ddb Compare November 8, 2024 12:01
@flostadler flostadler merged commit bc85ea7 into master Nov 8, 2024
32 checks passed
@flostadler flostadler deleted the flostadler/cfn-custom-resource-helpers branch November 8, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants