-
Notifications
You must be signed in to change notification settings - Fork 13
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
Unify asy conditionals and variables data structure #2494
Conversation
daved
commented
Apr 14, 2023
•
edited by github-actions
bot
Loading
edited by github-actions
bot
DX-1661 As a user I can access the same variables in scripts as I can in conditionals |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't done a full review as I feel like we can land this without any need for reflection. Figure we should address that before addressing the rest of the review.
Project *Project | ||
OS *OS | ||
Shell string | ||
Mixin func() *Mixin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing why this needs reflection. Why can't we give these values enough information to identify and act on their type differences? eg. add an interface with IsMixing()
for example.
pkg/projget/projget.go
Outdated
projVars := vars.New(auth, vars.NewProject(pj), shell) | ||
conditional := constraints.NewPrimeConditional(projVars) | ||
project.RegisterConditional(conditional) | ||
_ = project.RegisterStruct(projVars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed on call; we shouldn't need reflection to register the top level expanders. The cost of using reflection outweighs the value of having this behave in an automatic way where we can't accidentally introduce a top level conditional without also introducing a top level expander. Top level changes are so rare that it's overkill.
_ = project.RegisterStruct(projVars) | ||
} | ||
|
||
pj.SetUpdateCallback(registerProjectVars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this shouldn't be necessary as we are using the prime version of project.Projectfile, so we should always have access to the latest values already.
func NewProjectForTest(pjf *projectfile.Project) (*project.Project, error) { | ||
return newProject(output.Get(), nil, "noshell", pjf) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this to a *_test.go file.
Closing in favor of #2568. |