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 support for arbitrary JSON in attachments #259

Merged
merged 1 commit into from
May 30, 2019

Conversation

saary
Copy link
Contributor

@saary saary commented May 23, 2019

Allow storing arbitrary JSON structures within variants' attachment field

Description

Update the Attachment field type from map[string]string to map[string]interface{}

Motivation and Context

Enable using flagr as a smart general configuration store and remove hacks that use strings in order to store structured data

How Has This Been Tested?

The existing tests were updated to accommodate for this change

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-io
Copy link

codecov-io commented May 23, 2019

Codecov Report

Merging #259 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #259      +/-   ##
==========================================
- Coverage   81.89%   81.87%   -0.03%     
==========================================
  Files          26       26              
  Lines        1530     1528       -2     
==========================================
- Hits         1253     1251       -2     
+ Misses        209      208       -1     
- Partials       68       69       +1
Impacted Files Coverage Δ
pkg/entity/variant.go 88.23% <ø> (ø) ⬆️
pkg/entity/fixture.go 100% <100%> (ø) ⬆️
pkg/handler/crud.go 90.46% <0%> (-0.58%) ⬇️
pkg/handler/handler.go 85.41% <0%> (+3.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1293e27...a86d8c7. Read the comment docs.

pkg/handler/crud_test.go Show resolved Hide resolved
pkg/mapper/entity_restapi/r2e/r2e.go Outdated Show resolved Hide resolved
pkg/mapper/entity_restapi/r2e/r2e.go Outdated Show resolved Hide resolved
@saary saary force-pushed the master branch 7 times, most recently from ec1deba to e979450 Compare May 25, 2019 20:01
@saary
Copy link
Contributor Author

saary commented May 25, 2019

@zhouzhuojie Thanks for the feedback.
Fixed all comments and also added a test for a more complex structured attachment.

return e, fmt.Errorf("all key/value pairs should be string/string. invalid attachment format %s", spew.Sdump(a))
}
e[k] = s
return e, fmt.Errorf("Make sure JSON is properly formatted. Invalid attachment format %s", spew.Sdump(a))
Copy link
Collaborator

Choose a reason for hiding this comment

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

one last nit, JSON format actually supports things like naked string, number, or null. here we may want to say:

"Make sure JSON is properly formatted into key/value pairs."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, pushing a fix now if you want to take a quick look

@zhouzhuojie zhouzhuojie merged commit 5b923b8 into openflagr:master May 30, 2019
kgeorgiou added a commit to kgeorgiou/flagr that referenced this pull request Jul 27, 2019
Update Dynamic Configuration section to match the variant attachment format updates introduced in openflagr#259.
kgeorgiou added a commit to kgeorgiou/flagr that referenced this pull request Aug 8, 2019
Update Dynamic Configuration section to match the variant attachment format updates introduced in openflagr#259.
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.

3 participants