Skip to content

Commit

Permalink
remove use of unsupported BOM API
Browse files Browse the repository at this point in the history
The buildpacks spec has deprecated the BOM API and it is no longer supported in recent lifecycle versions. This commit removes our usage of it.

PiperOrigin-RevId: 693987532
Change-Id: I5fb8e09af703ead6da10b4cd692e7845ef9ee05f
  • Loading branch information
matthewrobertson authored and copybara-github committed Nov 7, 2024
1 parent 2060b4d commit 662ebcd
Show file tree
Hide file tree
Showing 19 changed files with 2 additions and 245 deletions.
26 changes: 0 additions & 26 deletions builders/dotnet/acceptance/gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,32 +110,6 @@ func TestAcceptanceDotNet(t *testing.T) {
FilesMustExist: []string{sdk, "/workspace/Startup.cs"},
MustRebuildOnChange: "/workspace/Startup.cs",
},
{
// This is a separate test case from Dev mode above because it has a fixed runtime version.
// Its only purpose is to test that the metadata is set correctly.
Name: "Dev mode metadata",
// Test is only intended to be run against a single version
VersionInclusionConstraint: "3",
App: "simple",
Env: []string{"GOOGLE_DEVMODE=1", "GOOGLE_RUNTIME_VERSION=3.1.409"},
MustUse: []string{dotnetSDK, dotnetRuntime, dotnetPublish},
BOM: []acceptance.BOMEntry{
{
Name: "devmode",
Metadata: map[string]interface{}{
"devmode.sync": []interface{}{
map[string]interface{}{"dest": "/workspace", "src": "**/*.cs"},
map[string]interface{}{"dest": "/workspace", "src": "*.csproj"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.fs"},
map[string]interface{}{"dest": "/workspace", "src": "*.fsproj"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.vb"},
map[string]interface{}{"dest": "/workspace", "src": "*.vbproj"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.resx"},
},
},
},
},
},
}

for _, tc := range acceptance.FilterTests(t, imageCtx, testCases) {
Expand Down
24 changes: 0 additions & 24 deletions builders/gcp/base/acceptance/dotnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,6 @@ func TestAcceptanceDotNet(t *testing.T) {
FilesMustExist: []string{sdk, "/workspace/Startup.cs"},
MustRebuildOnChange: "/workspace/Startup.cs",
},
{
// This is a separate test case from Dev mode above because it has a fixed runtime version.
// Its only purpose is to test that the metadata is set correctly.
Name: "Dev mode metadata",
App: "simple_dotnet6",
Env: []string{"GOOGLE_DEVMODE=1", "GOOGLE_RUNTIME_VERSION=6.0.402"},
MustUse: []string{dotnetSDK, dotnetRuntime, dotnetPublish},
BOM: []acceptance.BOMEntry{
{
Name: "devmode",
Metadata: map[string]interface{}{
"devmode.sync": []interface{}{
map[string]interface{}{"dest": "/workspace", "src": "**/*.cs"},
map[string]interface{}{"dest": "/workspace", "src": "*.csproj"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.fs"},
map[string]interface{}{"dest": "/workspace", "src": "*.fsproj"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.vb"},
map[string]interface{}{"dest": "/workspace", "src": "*.vbproj"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.resx"},
},
},
},
},
},
}
for _, tc := range acceptance.FilterTests(t, imageCtx, testCases) {
tc := tc
Expand Down
18 changes: 0 additions & 18 deletions builders/gcp/base/acceptance/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,6 @@ func TestAcceptanceGo(t *testing.T) {
FilesMustExist: []string{"/layers/google.go.runtime/go/bin/go", "/workspace/main.go"},
MustRebuildOnChange: "/workspace/main.go",
},
{
// This is a separate test case from Dev mode above because it has a fixed runtime version.
// Its only purpose is to test that the metadata is set correctly.
Name: "Dev mode metadata",
App: "simple_gomod",
Env: []string{"GOOGLE_DEVMODE=1", "GOOGLE_RUNTIME_VERSION=1.16.4"},
MustUse: []string{goRuntime, goBuild, goMod},
BOM: []acceptance.BOMEntry{
{
Name: "devmode",
Metadata: map[string]interface{}{
"devmode.sync": []interface{}{
map[string]interface{}{"dest": "/workspace", "src": "**/*.go"},
},
},
},
},
},
{
Name: "Go runtime version respected",
App: "simple_gomod",
Expand Down
23 changes: 0 additions & 23 deletions builders/gcp/base/acceptance/nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,6 @@ func TestAcceptanceNodeJs(t *testing.T) {
FilesMustExist: []string{"/workspace/server.js"},
MustRebuildOnChange: "/workspace/server.js",
},
{
// This is a separate test case from Dev mode above because it has a fixed runtime version.
// Its only purpose is to test that the metadata is set correctly.
Name: "Dev mode metadata",
App: "simple",
Env: []string{"GOOGLE_DEVMODE=1", "GOOGLE_RUNTIME_VERSION=14.19.3"},
MustUse: []string{nodeRuntime, nodeNPM},
BOM: []acceptance.BOMEntry{
{
Name: "devmode",
Metadata: map[string]interface{}{
"devmode.sync": []interface{}{
map[string]interface{}{"dest": "/workspace", "src": "**/*.js"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.mjs"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.coffee"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.litcoffee"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.json"},
map[string]interface{}{"dest": "/workspace", "src": "public/**"},
},
},
},
},
},
{
Name: "simple application (custom entrypoint)",
App: "custom_entrypoint",
Expand Down
20 changes: 0 additions & 20 deletions builders/go/acceptance/gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,6 @@ func TestAcceptance(t *testing.T) {
FilesMustExist: []string{"/layers/google.go.runtime/go/bin/go", "/workspace/main.go"},
MustRebuildOnChange: "/workspace/main.go",
},
{
// This is a separate test case from Dev mode above because it has a fixed runtime version.
// Its only purpose is to test that the metadata is set correctly.
Name: "Dev mode metadata",
// This test only runs against a single version of Go as it is unlikely to break across versions.
VersionInclusionConstraint: "1.16",
App: "simple",
Env: []string{"GOOGLE_DEVMODE=1", "GOOGLE_RUNTIME_VERSION=1.16.4"},
MustUse: []string{goRuntime, goBuild, goPath},
BOM: []acceptance.BOMEntry{
{
Name: "devmode",
Metadata: map[string]interface{}{
"devmode.sync": []interface{}{
map[string]interface{}{"dest": "/workspace", "src": "**/*.go"},
},
},
},
},
},
{
Name: "Go runtime version respected",
// This test only runs against a single version of Go as it is unlikely to break across versions.
Expand Down
25 changes: 0 additions & 25 deletions builders/nodejs/acceptance/gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,6 @@ func TestAcceptance(t *testing.T) {
FilesMustExist: []string{"/workspace/server.js"},
MustRebuildOnChange: "/workspace/server.js",
},
{
// This is a separate test case from Dev mode above because it has a fixed runtime version.
// Its only purpose is to test that the metadata is set correctly.
Name: "Dev mode metadata",
// Test installs a specific version of node and only needs to be run with a single version
VersionInclusionConstraint: "14",
App: "simple",
Env: []string{"GOOGLE_DEVMODE=1", "GOOGLE_RUNTIME_VERSION=14.19.3"},
MustUse: []string{nodeRuntime, nodeNPM},
BOM: []acceptance.BOMEntry{
{
Name: "devmode",
Metadata: map[string]interface{}{
"devmode.sync": []interface{}{
map[string]interface{}{"dest": "/workspace", "src": "**/*.js"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.mjs"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.coffee"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.litcoffee"},
map[string]interface{}{"dest": "/workspace", "src": "**/*.json"},
map[string]interface{}{"dest": "/workspace", "src": "public/**"},
},
},
},
},
},
{
Name: "simple application (custom entrypoint)",
App: "custom_entrypoint",
Expand Down
1 change: 0 additions & 1 deletion cmd/dotnet/publish/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func buildFn(ctx *gcp.Context) error {

// Configure the entrypoint and metadata for dev mode.
ctx.AddWebProcess([]string{"dotnet", "watch", "--project", proj, "run"})
devmode.AddSyncMetadata(ctx, devmode.DotNetSyncRules)
return nil
}

Expand Down
2 changes: 0 additions & 2 deletions cmd/go/build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ func buildFn(ctx *gcp.Context) error {
return fmt.Errorf("adding devmode file watcher: %w", err)
}

devmode.AddSyncMetadata(ctx, devmode.GoSyncRules)

return nil
}

Expand Down
1 change: 0 additions & 1 deletion cmd/java/entrypoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func buildFn(ctx *gcp.Context) error {

// Configure the entrypoint and metadata for dev mode.
if devmode.Enabled(ctx) {
devmode.AddSyncMetadata(ctx, devmode.JavaSyncRules)
if err := devmode.AddFileWatcherProcess(ctx, devmode.Config{
BuildCmd: []string{".devmode_rebuild.sh"},
RunCmd: command,
Expand Down
1 change: 0 additions & 1 deletion cmd/nodejs/npm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ NOTE: Running the default build script can be skipped by passing the empty envir
}); err != nil {
return fmt.Errorf("adding devmode file watcher: %w", err)
}
devmode.AddSyncMetadata(ctx, devmode.NodeSyncRules)

return nil
}
Expand Down
1 change: 0 additions & 1 deletion cmd/nodejs/yarn/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func buildFn(ctx *gcp.Context) error {
}); err != nil {
return fmt.Errorf("adding devmode file watcher: %w", err)
}
devmode.AddSyncMetadata(ctx, devmode.NodeSyncRules)

return nil
}
Expand Down
20 changes: 2 additions & 18 deletions internal/acceptance/acceptance.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"os/exec"
"path"
"path/filepath"
"reflect"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -176,8 +175,6 @@ type Test struct {
FlakyBuildAttempts int
// RequestType specifies the payload of the request used to test the function.
RequestType requestType
// BOM specifies the list of bill-of-material entries expected in the built image metadata.
BOM []BOMEntry
// Map from label name to expected value.
Labels map[string]string
// Setup is a function that sets up the source directory before test.
Expand Down Expand Up @@ -223,12 +220,6 @@ type ImageContext struct {
// test runs.
type setupFunc func(setupCtx SetupContext) error

// BOMEntry represents a bill-of-materials entry in the image metadata.
type BOMEntry struct {
Name string `json:"name"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}

// builderTOML contains the values from builder.toml file
type builderTOML struct {
Stack struct {
Expand Down Expand Up @@ -286,7 +277,7 @@ func testAppWithCache(t *testing.T, src, image, builderName, runName string, env

func testApp(t *testing.T, src, image, builderName, runName string, env map[string]string, cacheEnabled bool, checks *StructureTest, cfg Test) {
buildApp(t, src, image, builderName, runName, env, cacheEnabled, cfg)
verifyBuildMetadata(t, image, cfg.MustUse, cfg.MustNotUse, cfg.BOM)
verifyBuildMetadata(t, image, cfg.MustUse, cfg.MustNotUse)
verifyLabelValues(t, image, cfg.Labels)
verifyStructure(t, image, builderName, cacheEnabled, checks)
invokeApp(t, cfg, image, cacheEnabled)
Expand Down Expand Up @@ -1146,7 +1137,7 @@ func verifyLabelValues(t *testing.T, image string, labels map[string]string) {
}

// verifyBuildMetadata verifies the image was built with correct buildpacks.
func verifyBuildMetadata(t *testing.T, image string, mustUse, mustNotUse []string, bom []BOMEntry) {
func verifyBuildMetadata(t *testing.T, image string, mustUse, mustNotUse []string) {
t.Helper()

start := time.Now()
Expand All @@ -1156,7 +1147,6 @@ func verifyBuildMetadata(t *testing.T, image string, mustUse, mustNotUse []strin
}

var metadata struct {
BOM []BOMEntry `json:"bom"`
Buildpacks []struct {
ID string `json:"id"`
} `json:"buildpacks"`
Expand All @@ -1183,12 +1173,6 @@ func verifyBuildMetadata(t *testing.T, image string, mustUse, mustNotUse []strin
}
}

if len(bom) != 0 {
if got, want := metadata.BOM, bom; !reflect.DeepEqual(got, want) {
t.Errorf("Unexpected BOM on image metadata\ngot: %v\nwant %v", got, want)
}
}

t.Logf("Finished verifying build metadata (in %s)", time.Since(start))
}

Expand Down
1 change: 0 additions & 1 deletion pkg/devmode/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ go_library(
name = "devmode",
srcs = [
"devmode.go",
"dotnet.go",
"go.go",
"java.go",
"nodejs.go",
Expand Down
12 changes: 0 additions & 12 deletions pkg/devmode/devmode.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,6 @@ func AddFileWatcherProcess(ctx *gcp.Context, cfg Config) error {
return nil
}

// AddSyncMetadata adds sync metadata to the final image.
func AddSyncMetadata(ctx *gcp.Context, syncRulesFn func(string) []SyncRule) {
ctx.AddBOMEntry(libcnb.BOMEntry{
Name: "devmode",
Metadata: map[string]interface{}{
"devmode.sync": syncRulesFn(ctx.ApplicationRoot()),
},
Launch: true,
Build: true,
})
}

// writeBuildAndRunScript writes the contents of a file that builds code and then runs the resulting program
func writeBuildAndRunScript(ctx *gcp.Context, sl *libcnb.Layer, cfg Config) error {
sl.Launch = true
Expand Down
28 changes: 0 additions & 28 deletions pkg/devmode/dotnet.go

This file was deleted.

7 changes: 0 additions & 7 deletions pkg/devmode/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,3 @@ var (
// GoWatchedExtensions is the list of file extensions to be watched for changes in Dev Mode for Go.
GoWatchedExtensions = []string{"go"}
)

// GoSyncRules is the list of SyncRules to be configured in Dev Mode for Go.
func GoSyncRules(dest string) []SyncRule {
return []SyncRule{
{Src: "**/*.go", Dest: dest},
}
}
16 changes: 0 additions & 16 deletions pkg/devmode/java.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@ fi
`))
)

// JavaSyncRules is the list of SyncRules to be configured in Dev Mode for Java.
func JavaSyncRules(dest string) []SyncRule {
var rules []SyncRule

for _, ext := range JavaWatchedExtensions {
rules = append(rules, SyncRule{
Src: "**/*." + ext,
Dest: dest,
})
}

// TODO(dgageot): Also sync resources (html,css,js...).

return rules
}

// WriteBuildScript writes the build steps to a script to be run on each file change in dev mode.
func WriteBuildScript(ctx *gcp.Context, layerSrc, dest string, command []string) error {
var script bytes.Buffer
Expand Down
13 changes: 0 additions & 13 deletions pkg/devmode/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,3 @@ var (
// NodeWatchedExtensions is the list of file extensions to be watched for changes in Dev Mode for NodeJS.
NodeWatchedExtensions = []string{"js", "mjs", "coffee", "litcoffee", "json"}
)

// NodeSyncRules is the list of SyncRules to be configured in Dev Mode for NodeJS.
func NodeSyncRules(dest string) []SyncRule {
var rules []SyncRule
for _, ext := range NodeWatchedExtensions {
rules = append(rules, SyncRule{
Src: "**/*." + ext,
Dest: dest,
})
}

return append(rules, SyncRule{Src: "public/**", Dest: dest})
}
Loading

0 comments on commit 662ebcd

Please sign in to comment.