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

⚠️ Export scaffolding machinery #2082

Merged

Conversation

Adirio
Copy link
Contributor

@Adirio Adirio commented Mar 10, 2021

It is technically a breaking change (⚠️) because some errors that were previously placed in pkg/model and pkg/model/file have been moved to pkg/machinery and no longer expose NewXxxxxxError and IsXxxxxxxError functions, they expose themselves to use errors.As and errors.Is. It also removes the NewUniverse method and the WithXxxxx options are now part of the NewScaffold method, instead of having to pass a universe to every Execute call.

Closes: #2036
Blocked by: #2080

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 10, 2021
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 10, 2021
@Adirio
Copy link
Contributor Author

Adirio commented Mar 10, 2021

/test all

@Adirio Adirio mentioned this pull request Mar 11, 2021
14 tasks
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 14, 2021
Signed-off-by: Adrian Orive <adrian.orive.oneca@gmail.com>
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 14, 2021
@Adirio Adirio marked this pull request as ready for review March 14, 2021 20:36
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 14, 2021
@Adirio Adirio mentioned this pull request Mar 15, 2021
1 task
Copy link
Member

@camilamacedo86 camilamacedo86 left a 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

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 15, 2021
@k8s-ci-robot
Copy link
Contributor

[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:
  • OWNERS [Adirio,camilamacedo86]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 6ca3450 into kubernetes-sigs:master Mar 15, 2021
@@ -41,32 +49,96 @@ var options = imports.Options{
}

// Scaffold uses templates to scaffold new files
type Scaffold interface {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

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 means that we are sporting ScaffoldOption which has a unexported parameter. I avoided this when able.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@Adirio Adirio deleted the export-scaffold-machinery branch March 15, 2021 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Export scaffolding machinery
4 participants