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

refactor: look up default values on struct tag #996

Closed
wants to merge 12 commits into from

Conversation

fchikwekwe
Copy link
Contributor

Which problem is this PR solving?

Short description of the changes

  • add a struct tag lookup to getter funcs for fields that default to boolean true

@fchikwekwe fchikwekwe force-pushed the faith/lookup-struct-tags branch from dfb341b to 7d5e839 Compare February 16, 2024 08:10
@fchikwekwe fchikwekwe marked this pull request as ready for review February 16, 2024 08:58
@fchikwekwe fchikwekwe requested a review from a team as a code owner February 16, 2024 08:58
@MikeGoldsmith MikeGoldsmith added the type: maintenance The necessary chores to keep the dust off. label Feb 16, 2024
m.Mux.RLock()
defer m.Mux.RUnlock()

return m.AddHostMetadataToTrace
return m.AddHostMetadataToTraceVal, m.AddHostMetadataToTraceErr
Copy link
Contributor

@VinozzZ VinozzZ Feb 16, 2024

Choose a reason for hiding this comment

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

If we are changing GetAddHostMetadataToTrace() to use m.AddHostMetadataToTraceVal as the return value, we will need to assign AddHostMetadataToTraceVal to true in newStartedApp in app_test.go

config/mock.go Outdated
@@ -75,13 +77,17 @@ type MockConfig struct {
DryRun bool
DryRunFieldName string
AddHostMetadataToTrace bool
Copy link
Contributor

Choose a reason for hiding this comment

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

If we choose to use AddHostMetadataToTraceVal, we probably should delete AddHostMetadataToTrace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair. I was trying to limit my changes a bit so I introduced some duplication here, but if I get the build passing I will try to not duplicate these values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved this with the build fix. Thanks for the help!

Copy link
Contributor

@VinozzZ VinozzZ left a comment

Choose a reason for hiding this comment

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

Yahoo for fixing the default tag to true issue. I'm not certain that it's a good idea to parse the default tag each time when we try to read the value though. It feels wasted work for me. It would be nice if we could get the default value only once. I think that's maybe what you are working on in a following PR?

I'm thinking maybe it's worth taking the time to see whether using a pointer to represent the three states route works

@fchikwekwe
Copy link
Contributor Author

@VinozzZ Yeah I just spoke with @kentquirk and he agreed that its maybe not the best idea to lookup struct tags for every getter func call. There is an option to cache the struct tag values to maybe make this better. But I think the consensus here is that using a defaultTrue type would be the best solution. I'll open a separate PR for that work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: maintenance The necessary chores to keep the dust off.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants