Skip to content

Commit

Permalink
Add buildpack name to buildpack and builder metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Sambhav Kothari <[email protected]>
  • Loading branch information
sambhav committed Mar 30, 2021
1 parent f6b7827 commit 6e25fd1
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
simple/nested-level-1 nested-l1-version -
simple/nested-level-2 nested-l2-version -
ID NAME VERSION HOMEPAGE
noop.buildpack NOOP Buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack NOOP Buildpack noop.buildpack.version -
read/env Read Env Buildpack read-env-version -
simple/layers - simple-layers-version -
simple/nested-level-1 - nested-l1-version -
simple/nested-level-2 - nested-l2-version -

Detection Order:
└ Group #1:
Expand Down Expand Up @@ -77,13 +77,13 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
simple/nested-level-1 nested-l1-version -
simple/nested-level-2 nested-l2-version -
ID NAME VERSION HOMEPAGE
noop.buildpack NOOP Buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack NOOP Buildpack noop.buildpack.version -
read/env Read Env Buildpack read-env-version -
simple/layers - simple-layers-version -
simple/nested-level-1 - nested-l1-version -
simple/nested-level-2 - nested-l2-version -

Detection Order:
└ Group #1:
Expand Down
28 changes: 14 additions & 14 deletions acceptance/testdata/pack_fixtures/inspect_builder_nested_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
simple/nested-level-1 nested-l1-version -
simple/nested-level-2 nested-l2-version -
ID NAME VERSION HOMEPAGE
noop.buildpack NOOP Buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack NOOP Buildpack noop.buildpack.version -
read/env Read Env Buildpack read-env-version -
simple/layers - simple-layers-version -
simple/nested-level-1 - nested-l1-version -
simple/nested-level-2 - nested-l2-version -

Detection Order:
└ Group #1:
Expand Down Expand Up @@ -79,13 +79,13 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
simple/nested-level-1 nested-l1-version -
simple/nested-level-2 nested-l2-version -
ID NAME VERSION HOMEPAGE
noop.buildpack NOOP Buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack NOOP Buildpack noop.buildpack.version -
read/env Read Env Buildpack read-env-version -
simple/layers - simple-layers-version -
simple/nested-level-1 - nested-l1-version -
simple/nested-level-2 - nested-l2-version -

Detection Order:
└ Group #1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,18 @@
"buildpacks": [
{
"id": "noop.buildpack",
"name": "NOOP Buildpack",
"version": "noop.buildpack.later-version",
"homepage": "http://geocities.com/cool-bp"
},
{
"id": "noop.buildpack",
"name": "NOOP Buildpack",
"version": "noop.buildpack.version"
},
{
"id": "read/env",
"name": "Read Env Buildpack",
"version": "read-env-version"
},
{
Expand Down Expand Up @@ -133,15 +136,18 @@
"buildpacks": [
{
"id": "noop.buildpack",
"name": "NOOP Buildpack",
"version": "noop.buildpack.later-version",
"homepage": "http://geocities.com/cool-bp"
},
{
"id": "noop.buildpack",
"name": "NOOP Buildpack",
"version": "noop.buildpack.version"
},
{
"id": "read/env",
"name": "Read Env Buildpack",
"version": "read-env-version"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ default = false

[[remote_info.buildpacks]]
id = "noop.buildpack"
name = "NOOP Buildpack"
version = "noop.buildpack.later-version"
homepage = "http://geocities.com/cool-bp"

[[remote_info.buildpacks]]
id = "noop.buildpack"
name = "NOOP Buildpack"
version = "noop.buildpack.version"

[[remote_info.buildpacks]]
id = "read/env"
name = "Read Env Buildpack"
version = "read-env-version"

[[remote_info.buildpacks]]
Expand Down Expand Up @@ -109,15 +112,18 @@ default = false

[[local_info.buildpacks]]
id = "noop.buildpack"
name = "NOOP Buildpack"
version = "noop.buildpack.later-version"
homepage = "http://geocities.com/cool-bp"

[[local_info.buildpacks]]
id = "noop.buildpack"
name = "NOOP Buildpack"
version = "noop.buildpack.version"

[[local_info.buildpacks]]
id = "read/env"
name = "Read Env Buildpack"
version = "read-env-version"

[[local_info.buildpacks]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ remote_info:
- name: {{.run_image_mirror}}
buildpacks:
- id: noop.buildpack
name: NOOP Buildpack
version: noop.buildpack.later-version
homepage: http://geocities.com/cool-bp
- id: noop.buildpack
name: NOOP Buildpack
version: noop.buildpack.version
- id: read/env
name: Read Env Buildpack
version: read-env-version
- id: simple/layers
version: simple-layers-version
Expand Down Expand Up @@ -78,11 +81,14 @@ local_info:
- name: {{.run_image_mirror}}
buildpacks:
- id: noop.buildpack
name: NOOP Buildpack
version: noop.buildpack.later-version
homepage: http://geocities.com/cool-bp
- id: noop.buildpack
name: NOOP Buildpack
version: noop.buildpack.version
- id: read/env
name: Read Env Buildpack
version: read-env-version
- id: simple/layers
version: simple-layers-version
Expand Down
20 changes: 10 additions & 10 deletions acceptance/testdata/pack_fixtures/inspect_builder_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
ID NAME VERSION HOMEPAGE
noop.buildpack NOOP Buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack NOOP Buildpack noop.buildpack.version -
read/env Read Env Buildpack read-env-version -
simple/layers - simple-layers-version -

Detection Order:
└ Group #1:
Expand Down Expand Up @@ -73,11 +73,11 @@ Run Images:
{{.run_image_mirror}}

Buildpacks:
ID VERSION HOMEPAGE
noop.buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack noop.buildpack.version -
read/env read-env-version -
simple/layers simple-layers-version -
ID NAME VERSION HOMEPAGE
noop.buildpack NOOP Buildpack noop.buildpack.later-version http://geocities.com/cool-bp
noop.buildpack NOOP Buildpack noop.buildpack.version -
read/env Read Env Buildpack read-env-version -
simple/layers - simple-layers-version -

Detection Order:
└ Group #1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Stacks:
(none)

Buildpacks:
ID VERSION HOMEPAGE
simple/layers simple-layers-version -
simple/layers/parent simple-layers-parent-version -
ID NAME VERSION HOMEPAGE
simple/layers Simple Layers Buildpack simple-layers-version -
simple/layers/parent Simple Layers Parent Buildpack simple-layers-parent-version -

Detection Order:
└ Group #1:
Expand Down
8 changes: 6 additions & 2 deletions inspect_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ func testInspectBuilder(t *testing.T, when spec.G, it spec.S) {
{
"id": "test.bp.one",
"version": "test.bp.one.version",
"homepage": "http://geocities.com/cool-bp"
"homepage": "http://geocities.com/cool-bp",
"name": "one"
},
{
"id": "test.bp.two",
Expand Down Expand Up @@ -197,7 +198,8 @@ func testInspectBuilder(t *testing.T, when spec.G, it spec.S) {
}
],
"layerDiffID": "sha256:test.bp.one.sha256",
"homepage": "http://geocities.com/cool-bp"
"homepage": "http://geocities.com/cool-bp",
"name": "one"
}
},
"test.bp.two": {
Expand Down Expand Up @@ -230,6 +232,7 @@ func testInspectBuilder(t *testing.T, when spec.G, it spec.S) {
{
ID: "test.bp.one",
Version: "test.bp.one.version",
Name: "one",
Homepage: "http://geocities.com/cool-bp",
},
{
Expand Down Expand Up @@ -298,6 +301,7 @@ func testInspectBuilder(t *testing.T, when spec.G, it spec.S) {
},
LayerDiffID: "sha256:test.bp.one.sha256",
Homepage: "http://geocities.com/cool-bp",
Name: "one",
},
},
"test.bp.two": {
Expand Down
1 change: 1 addition & 0 deletions inspect_buildpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func extractBuildpacks(layersMd dist.BuildpackLayers) []dist.BuildpackInfo {
for version, layerInfo := range buildpackMap {
bp := dist.BuildpackInfo{
ID: buildpackID,
Name: layerInfo.Name,
Version: version,
Homepage: layerInfo.Homepage,
}
Expand Down
8 changes: 7 additions & 1 deletion inspect_buildpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
const buildpackageMetadataTag = `{
"id": "some/top-buildpack",
"version": "0.0.1",
"name": "top",
"homepage": "top-buildpack-homepage",
"stacks": [
{
Expand Down Expand Up @@ -144,7 +145,8 @@ const buildpackLayersTag = `{
}
],
"layerDiffID":"sha256:top-buildpack-diff-id",
"homepage":"top-buildpack-homepage"
"homepage":"top-buildpack-homepage",
"name": "top"
}
}
}`
Expand Down Expand Up @@ -198,6 +200,7 @@ func testInspectBuildpack(t *testing.T, when spec.G, it spec.S) {
BuildpackInfo: dist.BuildpackInfo{
ID: "some/top-buildpack",
Version: "0.0.1",
Name: "top",
Homepage: "top-buildpack-homepage",
},
Stacks: []dist.Stack{
Expand All @@ -224,6 +227,7 @@ func testInspectBuildpack(t *testing.T, when spec.G, it spec.S) {
{
ID: "some/top-buildpack",
Version: "0.0.1",
Name: "top",
Homepage: "top-buildpack-homepage",
},
},
Expand All @@ -234,6 +238,7 @@ func testInspectBuildpack(t *testing.T, when spec.G, it spec.S) {
BuildpackInfo: dist.BuildpackInfo{
ID: "some/top-buildpack",
Version: "0.0.1",
Name: "top",
Homepage: "top-buildpack-homepage",
},
Optional: false,
Expand Down Expand Up @@ -340,6 +345,7 @@ func testInspectBuildpack(t *testing.T, when spec.G, it spec.S) {
},
LayerDiffID: "sha256:top-buildpack-diff-id",
Homepage: "top-buildpack-homepage",
Name: "top",
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions internal/builder/writer/human_readable.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ func buildpacksOutput(buildpacks []dist.BuildpackInfo, builderName string) (stri
buildpacksTabWriter = tabwriter.NewWriter(spaceStrippingWriter, writerMinWidth, writerPadChar, buildpacksTabWidth, writerPadChar, writerFlags)
)

_, err := fmt.Fprint(buildpacksTabWriter, " ID\tVERSION\tHOMEPAGE\n")
_, err := fmt.Fprint(buildpacksTabWriter, " ID\tNAME\tVERSION\tHOMEPAGE\n")
if err != nil {
return "", []string{}, fmt.Errorf("writing to tab writer: %w", err)
}

for _, b := range buildpacks {
_, err = fmt.Fprintf(buildpacksTabWriter, " %s\t%s\t%s\n", b.ID, b.Version, strs.ValueOrDefault(b.Homepage, "-"))
_, err = fmt.Fprintf(buildpacksTabWriter, " %s\t%s\t%s\t%s\n", b.ID, strs.ValueOrDefault(b.Name, "-"), b.Version, strs.ValueOrDefault(b.Homepage, "-"))
if err != nil {
return "", []string{}, fmt.Errorf("writing to tab writer: %w", err)
}
Expand Down
24 changes: 12 additions & 12 deletions internal/builder/writer/human_readable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ Run Images:
second/default
Buildpacks:
ID VERSION HOMEPAGE
test.top.nested test.top.nested.version -
test.nested http://geocities.com/top-bp
test.bp.one test.bp.one.version http://geocities.com/cool-bp
test.bp.two test.bp.two.version -
test.bp.three test.bp.three.version -
ID NAME VERSION HOMEPAGE
test.top.nested - test.top.nested.version -
test.nested - http://geocities.com/top-bp
test.bp.one - test.bp.one.version http://geocities.com/cool-bp
test.bp.two - test.bp.two.version -
test.bp.three - test.bp.three.version -
Detection Order:
├ Group #1:
Expand Down Expand Up @@ -120,12 +120,12 @@ Run Images:
second/local-default
Buildpacks:
ID VERSION HOMEPAGE
test.top.nested test.top.nested.version -
test.nested http://geocities.com/top-bp
test.bp.one test.bp.one.version http://geocities.com/cool-bp
test.bp.two test.bp.two.version -
test.bp.three test.bp.three.version -
ID NAME VERSION HOMEPAGE
test.top.nested - test.top.nested.version -
test.nested - http://geocities.com/top-bp
test.bp.one - test.bp.one.version http://geocities.com/cool-bp
test.bp.two - test.bp.two.version -
test.bp.three - test.bp.three.version -
Detection Order:
├ Group #1:
Expand Down
Loading

0 comments on commit 6e25fd1

Please sign in to comment.