-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
⚠️ Export scaffolding machinery #2082
⚠️ Export scaffolding machinery #2082
Conversation
Skipping CI for Draft Pull Request. |
f1eb924
to
723aa72
Compare
/test all |
Signed-off-by: Adrian Orive <adrian.orive.oneca@gmail.com>
723aa72
to
61dcae6
Compare
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.
The change which was significant and was discussed in the meeting is: #2080. (which was approved and merged by Eric, who raised the concerns. )
This one is the only flag as breaking change because is moving things around and changing the names. However, the same feature options still in place. Also, it shows very small changes which means that shows fine we move forward here.
PS.: We also agree in the meetings/issues to export the machinery to remove this duplication from the consumer (SDK)
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Adirio, camilamacedo86 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -41,32 +49,96 @@ var options = imports.Options{ | |||
} | |||
|
|||
// Scaffold uses templates to scaffold new files | |||
type Scaffold interface { |
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.
Why was this changed to a struct?
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.
Because we were exporting a Option
that was a function on an unexported struct.
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.
You can do type ScaffoldOption func(*scaffold)
since the predefined options have access to the internal type.
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 would prefer ^ but it's an unimportant design decision.
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.
That means that we are sporting ScaffoldOption
which has a unexported parameter. I avoided this when able.
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.
That's a common practice. The set of options is fixed because Scaffold
's fields are unexported anyway.
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.
Oh, yes, I know. The result is exactly the same. But there was not added value by the interface either. And this way we don't have a unexported type in pkg.go.dev.
It is technically a breaking change (⚠️ ) because some errors that were previously placed in
pkg/model
andpkg/model/file
have been moved topkg/machinery
and no longer exposeNewXxxxxxError
andIsXxxxxxxError
functions, they expose themselves to useerrors.As
anderrors.Is
. It also removes theNewUniverse
method and theWithXxxxx
options are now part of theNewScaffold
method, instead of having to pass a universe to everyExecute
call.Closes: #2036
Blocked by: #2080