diff --git a/go.mod b/go.mod index 734b1a46b..b0a397ffc 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.5 require ( github.com/Dynatrace/libbuildpack-dynatrace v1.5.2 github.com/Masterminds/semver v1.5.0 - github.com/cloudfoundry/libbuildpack v0.0.0-20240716203800-e8e9729b7ef9 + github.com/cloudfoundry/libbuildpack v0.0.0-20240717165421-f2ae8069fcba github.com/cloudfoundry/switchblade v0.4.0 github.com/golang/mock v1.6.0 github.com/onsi/ginkgo v1.16.5 diff --git a/go.sum b/go.sum index 4d7e20453..906a2bcab 100644 --- a/go.sum +++ b/go.sum @@ -805,8 +805,8 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= -github.com/cloudfoundry/libbuildpack v0.0.0-20240716203800-e8e9729b7ef9 h1:YeMNiR2zeg+5eAFHHQc8HINsS6BPLCdkLCW3AmijHaw= -github.com/cloudfoundry/libbuildpack v0.0.0-20240716203800-e8e9729b7ef9/go.mod h1:kn4FHMwI8bTd9gT92wPGjXHzUvGcj8CkPxG8q3AGBAQ= +github.com/cloudfoundry/libbuildpack v0.0.0-20240717165421-f2ae8069fcba h1:RdbOeYpXLO3wdrQrKuQFUIl7aLx6cdk95Lh/uFwAA9c= +github.com/cloudfoundry/libbuildpack v0.0.0-20240717165421-f2ae8069fcba/go.mod h1:kn4FHMwI8bTd9gT92wPGjXHzUvGcj8CkPxG8q3AGBAQ= github.com/cloudfoundry/switchblade v0.4.0 h1:5/Au4nIbArl8Dcfq4UNfl8YxTtxOKUFd5IlrPtiBsyY= github.com/cloudfoundry/switchblade v0.4.0/go.mod h1:XwTsTm19YJxd0swwTNA+qaxhERQHeTrcDFV0teBzfew= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= diff --git a/src/nodejs/brats/brats_test.go b/src/nodejs/brats/brats_test.go index e3c7a5581..c66217e41 100644 --- a/src/nodejs/brats/brats_test.go +++ b/src/nodejs/brats/brats_test.go @@ -9,10 +9,7 @@ import ( var _ = Describe("Nodejs buildpack", func() { bratshelper.UnbuiltBuildpack("node", CopyBrats) - bratshelper.DeployingAnAppWithAnUpdatedVersionOfTheSameBuildpack(CopyBrats) - bratshelper.StagingWithBuildpackThatSetsEOL("node", CopyBrats) bratshelper.DeployAppWithExecutableProfileScript("node", CopyBrats) - bratshelper.DeployAnAppWithSensitiveEnvironmentVariables(CopyBrats) bratshelper.ForAllSupportedVersions("node", CopyBrats, func(nodeVersion string, app *cutlass.App) { PushApp(app) diff --git a/vendor/github.com/cloudfoundry/libbuildpack/bratshelper/tests.go b/vendor/github.com/cloudfoundry/libbuildpack/bratshelper/tests.go index dd69ee650..a4698967c 100644 --- a/vendor/github.com/cloudfoundry/libbuildpack/bratshelper/tests.go +++ b/vendor/github.com/cloudfoundry/libbuildpack/bratshelper/tests.go @@ -1,15 +1,10 @@ package bratshelper import ( - "archive/tar" - "compress/gzip" "fmt" - "io" - "io/ioutil" "os" "os/exec" "path/filepath" - "strings" "time" "github.com/cloudfoundry/libbuildpack" @@ -56,142 +51,6 @@ func UnbuiltBuildpack(depName string, copyBrats func(string) *cutlass.App) { }) } -func DeployingAnAppWithAnUpdatedVersionOfTheSameBuildpack(copyBrats func(string) *cutlass.App) { - Describe("deploying an app with an updated version of the same buildpack", func() { - var ( - bpName, stack string - app *cutlass.App - ) - BeforeEach(func() { - bpName = GenBpName("changing") - app = copyBrats("") - app.Buildpacks = []string{bpName + "_buildpack"} - stackAssociationSupported, err := cutlass.ApiGreaterThan("2.113.0") - Expect(err).ToNot(HaveOccurred()) - if stackAssociationSupported { - stack = app.Stack - } else { - stack = "" - } - }) - AfterEach(func() { - defaultCleanup(app) - Expect(cutlass.DeleteBuildpack(bpName)).To(Succeed()) - // With stacks, creating the buildpack twice will result in a second record, one with `nil` stack. - // We need to clean up both. - if count, err := cutlass.CountBuildpack(bpName, ""); err == nil && count > 0 { - Expect(cutlass.DeleteBuildpack(bpName)).To(Succeed(), "Attempted to delete buildpack %s", bpName) - } - // LTS errors when running `cf buildpacks`. Ignore that output. - count, err := cutlass.CountBuildpack(bpName, "") - if err == nil { - Expect(count).To(BeZero(), "There are %d %s buildpacks", count, bpName) - } - }) - - It("prints useful warning message to stdout", func() { - Expect(cutlass.CreateOrUpdateBuildpack(bpName, Data.UncachedFile, stack)).To(Succeed()) - PushApp(app) - Expect(app.Stdout.String()).ToNot(ContainSubstring("buildpack version changed from")) - - newFile, err := ModifyBuildpack(Data.UncachedFile, func(path string, r io.Reader) (io.Reader, error) { - if path == "VERSION" { - return strings.NewReader("NewVersion"), nil - } - return r, nil - }) - Expect(err).ToNot(HaveOccurred()) - - Expect(cutlass.CreateOrUpdateBuildpack(bpName, newFile, stack)).To(Succeed(), "Could not create or update %s on %s", bpName, stack) - PushApp(app) - Expect(app.Stdout.String()).To(MatchRegexp(`buildpack version changed from (\S+) to NewVersion`)) - }) - }) -} - -func StagingWithBuildpackThatSetsEOL(depName string, copyBrats func(string) *cutlass.App) { - Describe("staging with "+depName+" buildpack that sets EOL on dependency", func() { - var ( - eolDate, buildpackFile, bpName, stack string - app *cutlass.App - ) - JustBeforeEach(func() { - eolDate = time.Now().AddDate(0, 0, 10).Format("2006-01-02") - file, err := ModifyBuildpackManifest(buildpackFile, func(m *Manifest) { - for _, eol := range m.DependencyDeprecationDates { - if eol.Name == depName { - eol.Date = eolDate - } - } - }) - Expect(err).ToNot(HaveOccurred()) - bpName = GenBpName("eol") - app = copyBrats("") - app.Buildpacks = []string{bpName + "_buildpack"} - stackAssociationSupported, err := cutlass.ApiGreaterThan("2.113.0") - Expect(err).ToNot(HaveOccurred()) - if stackAssociationSupported { - stack = app.Stack - } else { - stack = "" - } - - Expect(cutlass.CreateOrUpdateBuildpack(bpName, file, stack)).To(Succeed()) - os.Remove(file) - - PushApp(app) - }) - AfterEach(func() { - defaultCleanup(app) - Expect(cutlass.DeleteBuildpack(bpName)).To(Succeed()) - }) - - Context("using an uncached buildpack", func() { - BeforeEach(func() { - buildpackFile = Data.UncachedFile - }) - It("warns about end of life", func() { - Expect(app.Stdout.String()).To(MatchRegexp(`WARNING.*` + depName + ` \S+ will no longer be available in new buildpacks released after`)) - }) - }) - - Context("using a cached buildpack", func() { - BeforeEach(func() { - buildpackFile = Data.CachedFile - }) - It("warns about end of life", func() { - Expect(app.Stdout.String()).To(MatchRegexp(`WARNING.*` + depName + ` \S+ will no longer be available in new buildpacks released after`)) - }) - }) - }) -} - -func StagingWithADepThatIsNotTheLatestConstrained(depName string, versionConstraint string, copyBrats func(string) *cutlass.App) { - Describe("staging with a version of "+depName+" that is not the latest patch release in the manifest", func() { - var app *cutlass.App - BeforeEach(func() { - manifest, err := libbuildpack.NewManifest(Data.BpDir, nil, time.Now()) - Expect(err).ToNot(HaveOccurred(), "Making new manifest from %s: error is %v", Data.BpDir, err) - versions, err := libbuildpack.FindMatchingVersions(versionConstraint, manifest.AllDependencyVersions(depName)) - Expect(err).ToNot(HaveOccurred(), "Finding matching version: error is %v", err) - app = copyBrats(versions[0]) - app.Buildpacks = []string{Data.Cached} - PushApp(app) - }) - AfterEach(func() { - defaultCleanup(app) - }) - - It("logs a warning that tells the user to upgrade the dependency", func() { - Expect(app.Stdout.String()).To(MatchRegexp("WARNING.*A newer version of " + depName + " is available in this buildpack")) - }) - }) -} - -func StagingWithADepThatIsNotTheLatest(depName string, copyBrats func(string) *cutlass.App) { - StagingWithADepThatIsNotTheLatestConstrained(depName, "x", copyBrats) -} - func DeployAppWithExecutableProfileScript(depName string, copyBrats func(string) *cutlass.App) { Describe("deploying an app that has an executable .profile script", func() { var app *cutlass.App @@ -225,45 +84,6 @@ func DeployAppWithExecutableProfileScript(depName string, copyBrats func(string) }) } -func DeployAnAppWithSensitiveEnvironmentVariables(copyBrats func(string) *cutlass.App) { - Describe("deploying an app that has sensitive environment variables", func() { - var app *cutlass.App - BeforeEach(func() { - app = copyBrats("") - app.Buildpacks = []string{Data.Cached} - app.SetEnv("MY_SPECIAL_VAR", "SUPER SENSITIVE DATA") - PushApp(app) - }) - AfterEach(func() { - defaultCleanup(app) - }) - - It("will not write credentials to the app droplet", func() { - Expect(app.DownloadDroplet(filepath.Join(app.Path, "droplet.tgz"))).To(Succeed()) - file, err := os.Open(filepath.Join(app.Path, "droplet.tgz")) - Expect(err).ToNot(HaveOccurred()) - defer file.Close() - gz, err := gzip.NewReader(file) - Expect(err).ToNot(HaveOccurred()) - defer gz.Close() - tr := tar.NewReader(gz) - - for { - hdr, err := tr.Next() - if err == io.EOF { - break - } - b, err := ioutil.ReadAll(tr) - for _, content := range []string{"MY_SPECIAL_VAR", "SUPER SENSITIVE DATA"} { - if strings.Contains(string(b), content) { - Fail(fmt.Sprintf("Found sensitive string %s in %s", content, hdr.Name)) - } - } - } - }) - }) -} - func ForAllSupportedVersions(depName string, copyBrats func(string) *cutlass.App, runTests func(string, *cutlass.App)) { Describe("For all supported "+depName+" versions", func() { bpDir, err := cutlass.FindRoot() diff --git a/vendor/modules.txt b/vendor/modules.txt index 0cad311ec..01524885c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -20,7 +20,7 @@ github.com/blang/semver # github.com/cenkalti/backoff/v4 v4.3.0 ## explicit; go 1.18 github.com/cenkalti/backoff/v4 -# github.com/cloudfoundry/libbuildpack v0.0.0-20240716203800-e8e9729b7ef9 +# github.com/cloudfoundry/libbuildpack v0.0.0-20240717165421-f2ae8069fcba ## explicit; go 1.22.5 github.com/cloudfoundry/libbuildpack github.com/cloudfoundry/libbuildpack/ansicleaner