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

Unify asy conditionals and variables data structure #2568

Open
wants to merge 32 commits into
base: version/0-40-0-RC1
Choose a base branch
from

Conversation

daved
Copy link
Contributor

@daved daved commented Jun 5, 2023

No description provided.

@daved daved force-pushed the green/fix_cond_vars-2.DX-1661 branch from c13b182 to 0c8f91c Compare June 6, 2023 02:37
Comment on lines +206 to +209
case "project":
return projectFile.Project, nil
case "lock":
return projectFile.Lock, nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"project" shadows the field "Vars.Project", and "lock" (at the top level) will be difficult to keep updated using the introduced design. It would be nice to either drop these or include them within the Projvars struct.

@daved daved requested a review from Naatan July 6, 2023 22:47
Copy link
Member

@Naatan Naatan left a comment

Choose a reason for hiding this comment

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

Sorry, I had to stop the review as I want to change too many things here to the point that I'd rather start over. There is too much complexity being introduced here. Yes, we want variable unification; but if the cost of that unification is significantly more complex code that needs to be maintained, we need to find a happy medium instead. Nothing wrong with the code itself, just that it does not feel like the right solution for the problem we're facing.

Compounding all of this is DX-1814 - which isn't a priority right now but ultimately will result in some significant changes in how we expose these variables.

I'm going to drop this story for now. We will probably come back to it at a later date but as of right now I feel like we've already burned more time on this than warranted, and we're not close enough to the finish line to keep it going.

End result is I just don't want to invest any more time on this right now. I'm sorry.

}
sshell := subshell.New(cfg)

pj, err := project.NewWithVars(out, auth, sshell.Shell())
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need a separate constructor for vars? Is this notably slower or something? This feels very error prone as we will have instances of project initialized with vars and instances without, and we have to just know which is which.

I'd prefer we implement this in a way where this is always the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done to not uproot existing usages that do not require Vars for this diff. I imagined a new story to cover making all project usages (more?) equal.

Path() string
URL() string
}
func NewPrimeConditional(structure interface{}) *Conditional {
Copy link
Member

Choose a reason for hiding this comment

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

  1. We're no longer using this as a prime property so naming this PrimeConditional is misleading. Also I don't think anything outside of the prime package should deal with the concept of primes.

  2. It doesn't seem like you ever send this anything other than *project.Vars, so why the interface? Passing it the typed vars may also allow us to get rid of more reflection. If the issue is import cycles; we can move vars to its own package. I had an issue with the name projvars, but that was about naming more than anything.

  3. This should just be part of NewConditional() IMO. There is no scenario I'm aware of where we use conditionals without a project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is old code written 2 years ago that I simplified.

@daved
Copy link
Contributor Author

daved commented Jul 12, 2023

I hear you, and accept this decision, and just want to voice that the complexity introduced is dependent on developer comfort rather than technical difficulty. It's about 200 lines introduced containing only basic reflection. One way we can get this same unification is something I've brought up in the past. That is to preprocess the references like $project.example into {{.Project.Example}} so that the reflection is performed by the template package logic rather than us duplicating it. The issue, again, is legacy dependence on global behavior. So the top-level "lock" and "project" values would be lost entirely (though, I think that is worth the loss).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants