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

Create config migration script #934

Merged
merged 10 commits into from
Aug 18, 2022
Merged

Create config migration script #934

merged 10 commits into from
Aug 18, 2022

Conversation

awrichar
Copy link
Contributor

@awrichar awrichar commented Aug 5, 2022

The goal here is to have a script that can detect configuration which was deprecated in a particular version of FireFly and then convert it to the newest format. By progressively iterating through versions, a config file may be brought up to date with the latest expected format.

The secondary goal is for this script to be as easy to maintain as possible. I've prototyped a partial solution in both Python and Go. Both have their advantages, so I'm looking for input on the final choice. In the end, the Python solution was not significantly simpler than the Go version, and would introduce a new language, packaging system, etc. I've decided to stick with Go.

@awrichar awrichar force-pushed the config branch 3 times, most recently from 7dad2ca to 0cae6a2 Compare August 5, 2022 16:21
Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Allows redirecting stdout to get only the new config text.

Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Aug 9, 2022

Codecov Report

Merging #934 (61fe7e6) into main (e22d84a) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 61fe7e6 differs from pull request most recent head e1042e6. Consider uploading reports for the commit e1042e6 to get more accurate results

@@            Coverage Diff             @@
##             main     #934      +/-   ##
==========================================
- Coverage   99.98%   99.97%   -0.02%     
==========================================
  Files         299      301       +2     
  Lines       19478    19687     +209     
==========================================
+ Hits        19475    19682     +207     
- Misses          3        4       +1     
- Partials        0        1       +1     
Impacted Files Coverage Δ
ffconfig/migrate/config.go 100.00% <100.00%> (ø)
ffconfig/migrate/migrations.go 100.00% <100.00%> (ø)
internal/tokens/fftokens/fftokens.go 99.53% <0.00%> (-0.47%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Signed-off-by: Andrew Richardson <[email protected]>
@awrichar awrichar force-pushed the config branch 2 times, most recently from d07e459 to bb3a202 Compare August 9, 2022 14:59
Signed-off-by: Andrew Richardson <[email protected]>
Copy link
Contributor

@nguyer nguyer left a comment

Choose a reason for hiding this comment

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

Looks good. Just a couple of minor suggestions for improvemnets.

func Run(cfg []byte, fromVersion, toVersion string) (result []byte, err error) {
var from, to semver.Version
if fromVersion != "" {
if from, err = semver.Parse(fromVersion); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a minor suggestion, but we tag all of our versions as v1.x.x. Which is technically not semver. Because we put the v in front of it. But it's typical for Go versions. Anyway, if we could make this function optionally accept and trim a v prefix, that might make it more user friendly for someone who routinely types out the version number by hand.


### Migration

Migrating a config file will remove all deprecated config for a particular version of FireFly, and replace it with
Copy link
Contributor

Choose a reason for hiding this comment

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

I might suggest slightly re-wording this. When I first read this (before I read the code) I wasn't sure if it would re-write my config in place. I think the phrase "remove all deprecated config" sounds a bit scary. Something along the lines of making it clear that this tool generates a copy of your config in the new structure.

Also allow "v" prefix on versions passed to the script.

Signed-off-by: Andrew Richardson <[email protected]>
@awrichar awrichar merged commit 7b821a4 into hyperledger:main Aug 18, 2022
@awrichar awrichar deleted the config branch August 18, 2022 16:02
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