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

feat(gnoland): in config, refer to fields using toml struct tags #1769

Merged
merged 5 commits into from
Mar 26, 2024

Conversation

thehowl
Copy link
Member

@thehowl thehowl commented Mar 13, 2024

After briefly discussing #1605, me and @zivkovicmilos convened that it would be better if the config commands took, for the keys in the configuration, their TOML name rather than the internal Go struct field name. This PR implements that.

@thehowl thehowl self-assigned this Mar 13, 2024
@github-actions github-actions bot added 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Mar 13, 2024
Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 72.97297% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 47.51%. Comparing base (41ff374) to head (3348d13).

Files Patch % Lines
gno.land/cmd/gnoland/config.go 72.97% 8 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1769      +/-   ##
==========================================
+ Coverage   47.49%   47.51%   +0.02%     
==========================================
  Files         388      388              
  Lines       61305    61331      +26     
==========================================
+ Hits        29117    29144      +27     
+ Misses      29750    29747       -3     
- Partials     2438     2440       +2     

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

Copy link
Contributor

@deelawn deelawn 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 to me. The smallest suggestion I have is to change the name of the callback function from cb to something that describes what is going on; it also helps to understand what the boolean returned means.

At most I'd suggest removing the callback function in favor of an interface like

type valueSetter interface {
    Set(name string, value reflect.Value) (ok bool)
}

And then make the necessary changes around it. I think that using interfaces over callbacks makes it easier to understand. Not required to be merged though.

@thehowl
Copy link
Member Author

thehowl commented Mar 20, 2024

@deelawn

Looks good to me. The smallest suggestion I have is to change the name of the callback function from cb to something that describes what is going on; it also helps to understand what the boolean returned means.

done!

as for your suggestion, it probably requires a bigger overhaul of the whole config system. keep in mind I designed it this way because it could also easily support just reading the fields (rather than setting them), so an "iterator-ish" approach is more proper IMO.

Copy link
Member

@zivkovicmilos zivkovicmilos 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 💯

I've left minor comments 🙏

gno.land/cmd/gnoland/config.go Outdated Show resolved Hide resolved
gno.land/cmd/gnoland/config.go Show resolved Hide resolved
@thehowl thehowl merged commit 281815a into master Mar 26, 2024
182 of 183 checks passed
@thehowl thehowl deleted the dev/morgan/gnoland-config-toml branch March 26, 2024 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related
Projects
Status: Done
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants