3.7 KiB
Meta
- Name: Pack Command to Create a Buildpack Repo
- Start Date: 2021-01-19
- Author(s): jkutner
- Status: Superseded
- RFC Pull Request: rfcs#136
- CNB Pull Request: (leave blank)
- CNB Issue: buildpacks/pack#1025
- Supersedes: N/A
Summary
This is a proposal for a new command in Pack that would create the scaffolding for a new buildpack.
Definitions
- Scaffold - the essential files and directories required for a buildpack
Motivation
Every new buildpack requires a few essential files and directories. We can make buildpack development easier by automatically generating these with a single command.
What it is
Add a new command to Pack:
$ pack buildpack new <id> \
--api <api> \
--name <name> \
--path <path> \
--stack <stack> \
--version <version>
Where the flags include:
api- the buildpack API compatibility versionname- the name of the buildpack in thebuildpack.tomlpath- the location on the filesystem to generate the artifactsstack- a set of compatible stacks for the buildpack. may be specificied multiple times. (defaults toio.buildpacks.stacks.bionicbecause it is required)version- the version of the buildpack inbuildpack.toml(defaults to0.0.0because it is required)
The command will create a directory named for the buildpack ID, or the second component of a <namespace>/<name> ID. Inside of that directory, it will generate the minimal artifacts required to implement a buildpack in Bash.
The pack buildpack new is only a generator. It will not be a living command (i.e. you cannot re-run it to update a buildpack).
Future Work
In the future, we may add support for a --template flag, which would create buildpacks from templates stored in a curated repository. In this way we can support many different languages, and even support versions the same language with different opinions.
How it Works
See https://github.com/buildpacks/pack/pull/1025
The only supported language will be Bash. This is based on CNB user research, which found:
Comfort with Go is required to interpret buildpacks / paketo source code
- We assume Go experience is not something we can expect our users to have
Part of the reason developers take to docker easily is because the commands are similar to shell scripts
- We assume shell scripts is what devs will be most comfortable with / wil analogize from
The generated files will include:
buildpack.tomlbin/buildbin/detect
The buildpack.toml will be pre-poluated with the values provided in the CLI command and some defaults (like 0.0.0 for the version).
The bin/ scripts will be made executable on Linux and MacOS platforms.
Drawbacks
- Might be too opinionated, especially in a compiled language, or a language that uses a library.
Alternatives
- Do it by hand
- A separate tool (not Pack) can create the scaffolding
Prior Art
Unresolved Questions
- What language(s) would we support?
- Golang
- Bash
- Python?
- Should we generate test stubs?