buildpacks / pack

CLI for building apps using Cloud Native Buildpacks
https://buildpacks.io
Apache License 2.0
2.56k stars 286 forks source link

Allow buildpack versions in builder.toml and validate them #187

Closed ekcasey closed 5 years ago

ameyer-pivotal commented 5 years ago

We should enforce that the buildpack ID in the builder.toml matches the buildpack's own buildpack.toml ID too, though this could be a separate story

ekcasey commented 5 years ago

@ameyer-pivotal I think we already validate the ID https://github.com/buildpack/pack/blob/master/create_builder.go#L64-L66

mgibson1121 commented 5 years ago

@ameyer-pivotal @ekcasey What is the scope of this story? Just to validate when creating the builder that the specified version exists at the specified id? If so it passes, but are there any other cases?

ameyer-pivotal commented 5 years ago

@mgibson1121 This story adds an optional version field next to the id field for a buildpack in the builder.toml (top-level buildpacks, not those within groups [they already have a version field]).

If omitted, does nothing.

If version supplied, it must match version inside buildpack's builder.toml file. You should see an error if they mismatch. Hope that helps. Let me know if you run into any trouble :)

mgibson1121 commented 5 years ago

@ameyer-pivotal Based on your comment, I would expect the create-builder command to fail when it runs against the following builder, but it succeeds:

y-floater-5895:builder pivotal$ cat builder-6.toml
description = "This builder is the best"

[[buildpacks]]
id = "org.cloudfoundry.buildpacks.npm"
uri = "https://github.com/cloudfoundry/npm-cnb/releases/download/v0.0.7/npm-cnb-0.0.7.tgz"

[[buildpacks]]
id = "org.cloudfoundry.buildpacks.nodejs"
version = "1231232131233123"
uri = "https://github.com/cloudfoundry/nodejs-cnb/releases/download/v0.0.6/nodejs-cnb-0.0.6.tgz"

[[groups]]
  [[groups.buildpacks]]
    id = "org.cloudfoundry.buildpacks.nodejs"
    version = "0.0.6"

  [[groups.buildpacks]]
    id = "org.cloudfoundry.buildpacks.npm"
    version = "0.0.7"

[stack]
id = "io.buildpacks.stacks.bionic"
build-image = "gcr.io/cncf-buildpacks-ci/packs/build:0.2.0-build.9"
run-image = "gcr.io/cncf-buildpacks-ci/packs/run:0.2.0-build.9"

[lifecycle]
uri = "file:///Users/pivotal/Downloads/lifecycle-v0.2.0-build.14+linux.x86-64.tgz"
version = "v0.2.0"
mgibson1121 commented 5 years ago

Moving back to in progress because of the above.

djoyahoy commented 5 years ago

@mgibson1121 we ran pack on the provided builder.toml and we did get the error:

ERROR: buildpack from URI 'https://github.com/cloudfoundry/nodejs-cnb/releases/download/v0.0.6/nodejs-cnb-0.0.6.tgz' has version '0.0.6' which does not match version '1231232131233123' from builder config

Maybe we can sync up and figure out what's wrong?

mgibson1121 commented 5 years ago

Didn't install the latest version of pack correctly, triggering the behavior for a previous pack release. This story passes acceptance.

ekcasey commented 5 years ago

done on master, will ship in v0.3.0