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

Sub-team RFC for lifecycle package re-organization #217

Closed
wants to merge 2 commits into from

Conversation

natalieparellano
Copy link
Member

@natalieparellano natalieparellano commented Apr 15, 2022

Signed-off-by: Natalie Arellano <narellano@vmware.com>
@natalieparellano natalieparellano added team/implementation scope/team RFC scoped to a sub-team as opposed to the entire project. labels Apr 15, 2022
@natalieparellano natalieparellano requested a review from a team as a code owner April 15, 2022 20:41
@buildpack-bot
Copy link
Member

Maintainers,

As you review this RFC please queue up issues to be created using the following commands:

/queue-issue <repo> "<title>" [labels]...
/unqueue-issue <uid>

Issues

(none)

│ ├── archive
│ ├── buildpack
│ │ ├── env
│ │ ├── launch
Copy link
Member Author

Choose a reason for hiding this comment

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

Actually nothing in buildpack imports this code. Maybe it should live at pkg/launch.


* The structure of the lifecycle should mirror the spec as much as possible. However we should recognize that the spec is not perfect. Also, while there is a `lifecycle` package, there is no "lifecycle spec" - the responsibilities of the lifecycle are mixed between the platform and buildpack specs (see below).
* In general the `lifecycle` package should be more of an orchestrator - see [example](https://github.com/buildpacks/lifecycle/blob/b6803be364429689a818a5d0a09db42bd21b9995/analyzer.go#L52-L54). We should push as much logic as possible into services.
* CNB business logic should live inside the `buildpack`, `lifecycle`, and `platform` packages (and their nested packages) or their `internal` equivalents. All other packages that are direct children of `pkg` or `internal` should be CNB-free.
Copy link
Member Author

Choose a reason for hiding this comment

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

I think having some sort of rule like this will help us keep our packages well scoped.

* The structure of the lifecycle should mirror the spec as much as possible. However we should recognize that the spec is not perfect. Also, while there is a `lifecycle` package, there is no "lifecycle spec" - the responsibilities of the lifecycle are mixed between the platform and buildpack specs (see below).
* In general the `lifecycle` package should be more of an orchestrator - see [example](https://github.com/buildpacks/lifecycle/blob/b6803be364429689a818a5d0a09db42bd21b9995/analyzer.go#L52-L54). We should push as much logic as possible into services.
* CNB business logic should live inside the `buildpack`, `lifecycle`, and `platform` packages (and their nested packages) or their `internal` equivalents. All other packages that are direct children of `pkg` or `internal` should be CNB-free.
* Logic that branches on api version should be handled by an internal service nested under the appropriate package - e.g., logic that branches on buildpack api should live in `internal/buildpack` - see [example](https://github.com/buildpacks/lifecycle/blob/b6803be364429689a818a5d0a09db42bd21b9995/buildpack/bom.go#L14-L23).
Copy link
Member Author

Choose a reason for hiding this comment

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

This to me feels like the most helpful organizing principle. Instead of having a bunch of if api.MustParse(platformAPI).AtLeast("XXX") sprinkled throughout the code, we can consolidate the branching logic in the constructor, by giving our orchestrator the right services for the api it implements.

[alternatives]: #alternatives

- What other designs have been considered? Doing nothing, just keep adding code as best we can.
- Why is this proposal the best? Making it easier to add new code will allow us to deliver features faster.
Copy link
Member Author

Choose a reason for hiding this comment

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

Another benefit of having a well-organized lifecycle is that by adding good README files and docs comments, we can turn the lifecycle into an easy-to-consume repository of information for further understanding the CNB spec.

Signed-off-by: Natalie Arellano <narellano@vmware.com>
- Launch
- Platform inputs and outputs (args, flags, env vars, mounts, exit codes)
- Registry auth
- Buildpacks directory layout
Copy link
Member Author

Choose a reason for hiding this comment

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

It has always sort of bothered me that the buildpack package contains DirBuildpackStore and I think this is why!

Comment on lines +85 to +87
│ ├── inputs # handles platform <-> lifecycle interface (args, flags)
│ ├── launch
│ │ └── inputs # handles platform <-> launcher interface (args, flags)
Copy link
Member Author

Choose a reason for hiding this comment

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

@natalieparellano
Copy link
Member Author

Closing this RFC as ideas have evolved somewhat since its inception, though as an instrument for thinking things through it was still useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope/team RFC scoped to a sub-team as opposed to the entire project. team/implementation type/rfc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants