Skip to content

Commit

Permalink
Adds support for targets in the builder config
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestEckhardt authored and sophiewigmore committed Apr 18, 2024
1 parent 9912621 commit 14b6860
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
10 changes: 9 additions & 1 deletion integration/update_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func testUpdateBuilder(t *testing.T, context spec.G, it spec.S) {
nodeConfigPath := fmt.Sprintf("/v2/paketobuildpacks/nodejs/blobs/%s", mustConfigName(t, nodeImg))
nodeManifestReqCount := 0
extensionManifestPath := "/v2/paketocommunity/ubi-nodejs-extension/manifests/0.0.3"
extensionConfigPath := fmt.Sprintf("/v2/paketocommunity/ubi-nodejs-extension/blobs/%s", mustConfigName(t, extensionImg))
extensionConfigPath := fmt.Sprintf("/v2/paketocommunity/ubi-nodejs-extension/blobs/%s", mustConfigName(t, extensionImg))
extensionManifestReqCount := 0
server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {

Expand Down Expand Up @@ -258,6 +258,10 @@ description = "Some description"
build-image = "REGISTRY-URI/somerepository/build:0.0.10-some-cnb"
run-image = "REGISTRY-URI/somerepository/run:some-cnb"
run-image-mirrors = ["REGISTRY-URI/some-repository/run:some-cnb"]
[[targets]]
os = "linux"
arch = "amd64"
`), []byte(`REGISTRY-URI`), []byte(strings.TrimPrefix(server.URL, "http://"))), 0600)
Expect(err).NotTo(HaveOccurred())
})
Expand Down Expand Up @@ -324,6 +328,10 @@ description = "Some description"
id = "io.paketo.stacks.some-stack"
run-image = "REGISTRY-URI/somerepository/run:some-cnb"
run-image-mirrors = ["REGISTRY-URI/some-repository/run:some-cnb"]
[[targets]]
os = "linux"
arch = "amd64"
`, "REGISTRY-URI", strings.TrimPrefix(server.URL, "http://"))))
})

Expand Down
6 changes: 6 additions & 0 deletions internal/builder_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type BuilderConfig struct {
Extensions []BuilderConfigExtension `toml:"extensions"`
OrderExtension []BuilderExtensionConfigOrder `toml:"order-extensions"`
Stack BuilderConfigStack `toml:"stack"`
Targets []BuilderConfigTarget `toml:"targets"`
}

type BuilderConfigBuildpack struct {
Expand Down Expand Up @@ -61,6 +62,11 @@ type BuilderConfigStack struct {
RunImageMirrors []string `toml:"run-image-mirrors"`
}

type BuilderConfigTarget struct {
OS string `toml:"os"`
Arch string `toml:"arch"`
}

// Note: this is to support that buildpackages can refer to this field as `image` or `uri`.
func (b *BuilderConfigBuildpack) UnmarshalTOML(v interface{}) error {
if m, ok := v.(map[string]interface{}); ok {
Expand Down
56 changes: 55 additions & 1 deletion internal/builder_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ description = "Some description"
build-image = "some-registry/somerepository/build:1.2.3-some-cnb"
run-image = "some-registry/somerepository/run:some-cnb"
run-image-mirrors = ["some-registry/some-repository/run:some-cnb"]
[[targets]]
os = "linux"
arch = "amd64"
[[targets]]
os = "linux"
arch = "arm64"
`)
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -135,6 +143,16 @@ description = "Some description"
RunImage: "some-registry/somerepository/run:some-cnb",
RunImageMirrors: []string{"some-registry/some-repository/run:some-cnb"},
},
Targets: []internal.BuilderConfigTarget{
{
OS: "linux",
Arch: "amd64",
},
{
OS: "linux",
Arch: "arm64",
},
},
}))
})

Expand Down Expand Up @@ -262,6 +280,16 @@ description = "Some description"
RunImage: "some-registry/somerepository/run:some-cnb",
RunImageMirrors: []string{"some-registry/some-repository/run:some-cnb"},
},
Targets: []internal.BuilderConfigTarget{
{
OS: "linux",
Arch: "amd64",
},
{
OS: "linux",
Arch: "arm64",
},
},
})
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -309,6 +337,14 @@ description = "Some description"
build-image = "some-registry/somerepository/build:1.2.3-some-cnb"
run-image = "some-registry/somerepository/run:some-cnb"
run-image-mirrors = ["some-registry/some-repository/run:some-cnb"]
[[targets]]
os = "linux"
arch = "amd64"
[[targets]]
os = "linux"
arch = "arm64"
`))
})

Expand Down Expand Up @@ -352,6 +388,16 @@ description = "Some description"
RunImage: "some-registry/somerepository/run:some-cnb",
RunImageMirrors: []string{"some-registry/some-repository/run:some-cnb"},
},
Targets: []internal.BuilderConfigTarget{
{
OS: "linux",
Arch: "amd64",
},
{
OS: "linux",
Arch: "arm64",
},
},
})
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -388,9 +434,17 @@ description = "Some description"
build-image = "some-registry/somerepository/build:1.2.3-some-cnb"
run-image = "some-registry/somerepository/run:some-cnb"
run-image-mirrors = ["some-registry/some-repository/run:some-cnb"]
`))
[[targets]]
os = "linux"
arch = "amd64"
[[targets]]
os = "linux"
arch = "arm64"
`))
})

context("failure cases", func() {
context("when the file cannot be opened", func() {
it.Before(func() {
Expand Down

0 comments on commit 14b6860

Please sign in to comment.