Skip to content

Commit

Permalink
feat: Add config option for python buildpack name (#1415)
Browse files Browse the repository at this point in the history
Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
  • Loading branch information
nicolasbender and c0d1ngm0nk3y authored Jan 13, 2025
1 parent 1f9d25e commit a55e671
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ include_app_syslog_tcp
* `r_buildpack_name` [See below](#buildpack-names)
* `binary_buildpack_name` [See below](#buildpack-names)
* `cnb_nodejs_buildpack_name` [See below](#buildpack-names)
* `python_buildpack_name: python_buildpack` [See below](#buildpack-names)

* `include_windows`: Flag to include the tests that run against Windows cells.
* `use_windows_test_task`: Flag to include the tasks tests on Windows cells. Default is `false`.
Expand Down Expand Up @@ -203,6 +204,7 @@ Many tests specify a buildpack when pushing an app, so that on diego the app sta
* `r_buildpack_name: r_buildpack`
* `binary_buildpack_name: binary_buildpack`
* `hwc_buildpack_name: hwc_buildpack`
* `python_buildpack_name: python_buildpack`

For the Cloud Native Buildpacks lifecycle, you can override them by setting different names:

Expand Down
5 changes: 3 additions & 2 deletions apps/crashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package apps
import (
"encoding/json"
"fmt"
"time"

. "github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/app_helpers"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"
Expand All @@ -13,7 +15,6 @@ import (
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"
"time"
)

func hasOneInstanceInState(processPath, desiredState string) bool {
Expand Down Expand Up @@ -78,7 +79,7 @@ var _ = AppsDescribe("Crashing", func() {
By("Pushing the app with three instances")
Expect(cf.Cf(
"push", appName,
"-b", "python_buildpack",
"-b", Config.GetPythonBuildpackName(),
"-m", DEFAULT_MEMORY_LIMIT,
"-p", assets.NewAssets().PythonCrashApp,
"-i", "3", // Setting three instances
Expand Down
1 change: 1 addition & 0 deletions cats_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
Expect(buildpacks).To(ContainSubstring(Config.GetJavaBuildpackName()), "Missing the java buildpack specified in the integration_config.json. There may be other missing buildpacks as well; please double-check your configuration against the buildpacks listed below.")
Expect(buildpacks).To(ContainSubstring(Config.GetNodejsBuildpackName()), "Missing the NodeJS buildpack specified in the integration_config.json. There may be other missing buildpacks as well; please double-check your configuration against the buildpacks listed below.")
Expect(buildpacks).To(ContainSubstring(Config.GetRubyBuildpackName()), "Missing the ruby buildpack specified in the integration_config.json. There may be other missing buildpacks as well; please double-check your configuration against the buildpacks listed below.")
Expect(buildpacks).To(ContainSubstring(Config.GetPythonBuildpackName()), "Missing the python buildpack specified in the integration_config.json. There may be other missing buildpacks as well; please double-check your configuration against the buildpacks listed below.")
})

TestSetup.Setup()
Expand Down
1 change: 1 addition & 0 deletions helpers/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type CatsConfig interface {
GetNodejsBuildpackName() string
GetCNBGoBuildpackName() string
GetCNBNodejsBuildpackName() string
GetPythonBuildpackName() string
GetPrivateDockerRegistryImage() string
GetPrivateDockerRegistryUsername() string
GetPrivateDockerRegistryPassword() string
Expand Down
9 changes: 9 additions & 0 deletions helpers/config/config_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type config struct {
RBuildpackName *string `json:"r_buildpack_name"`
RubyBuildpackName *string `json:"ruby_buildpack_name"`
StaticFileBuildpackName *string `json:"staticfile_buildpack_name"`
PythonBuildpackName *string `json:"python_buildpack_name"`

CNBGoBuildpackName *string `json:"cnb_go_buildpack_name"`
CNBNodejsBuildpackName *string `json:"cnb_nodejs_buildpack_name"`
Expand Down Expand Up @@ -166,6 +167,7 @@ func getDefaults() config {
defaults.RBuildpackName = ptrToString("r_buildpack")
defaults.RubyBuildpackName = ptrToString("ruby_buildpack")
defaults.StaticFileBuildpackName = ptrToString("staticfile_buildpack")
defaults.PythonBuildpackName = ptrToString("python_buildpack")

defaults.CNBGoBuildpackName = ptrToString("docker://gcr.io/paketo-buildpacks/go:latest")
defaults.CNBNodejsBuildpackName = ptrToString("docker://gcr.io/paketo-buildpacks/nodejs:latest")
Expand Down Expand Up @@ -429,6 +431,9 @@ func validateConfig(config *config) error {
if config.CNBNodejsBuildpackName == nil {
errs = errors.Join(errs, fmt.Errorf("* 'cnb_nodejs_buildpack_name' must not be null"))
}
if config.PythonBuildpackName == nil {
errs = errors.Join(errs, fmt.Errorf("* 'python_buildpack_name' must not be null"))
}
if config.IncludeAppSyslogTCP == nil {
errs = errors.Join(errs, fmt.Errorf("* 'include_app_syslog_tcp' must not be null"))
}
Expand Down Expand Up @@ -1124,6 +1129,10 @@ func (c *config) GetCNBNodejsBuildpackName() string {
return *c.CNBNodejsBuildpackName
}

func (c *config) GetPythonBuildpackName() string {
return *c.PythonBuildpackName
}

func (c *config) GetPrivateDockerRegistryImage() string {
return *c.PrivateDockerRegistryImage
}
Expand Down
6 changes: 6 additions & 0 deletions helpers/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type testConfig struct {
RBuildpackName *string `json:"r_buildpack_name,omitempty"`
RubyBuildpackName *string `json:"ruby_buildpack_name,omitempty"`
StaticFileBuildpackName *string `json:"staticfile_buildpack_name,omitempty"`
PythonBuildpackName *string `json:"python_buildpack_name,omitempty"`
}

type nullConfig struct {
Expand Down Expand Up @@ -144,6 +145,7 @@ type nullConfig struct {
RBuildpackName *string `json:"r_buildpack_name"`
RubyBuildpackName *string `json:"ruby_buildpack_name"`
StaticFileBuildpackName *string `json:"staticfile_buildpack_name"`
PythonBuildpackName *string `json:"python_buildpack_name"`

ReporterConfig *testReporterConfig `json:"reporter_config"`

Expand Down Expand Up @@ -358,6 +360,7 @@ var _ = Describe("Config", func() {
Expect(config.GetRBuildpackName()).To(Equal("r_buildpack"))
Expect(config.GetRubyBuildpackName()).To(Equal("ruby_buildpack"))
Expect(config.GetStaticFileBuildpackName()).To(Equal("staticfile_buildpack"))
Expect(config.GetPythonBuildpackName()).To(Equal("python_buildpack"))
})

Context("when all values are null", func() {
Expand Down Expand Up @@ -404,6 +407,7 @@ var _ = Describe("Config", func() {
Expect(err.Error()).To(ContainSubstring("'nodejs_buildpack_name' must not be null"))
Expect(err.Error()).To(ContainSubstring("'ruby_buildpack_name' must not be null"))
Expect(err.Error()).To(ContainSubstring("'staticfile_buildpack_name' must not be null"))
Expect(err.Error()).To(ContainSubstring("'python_buildpack_name' must not be null"))

Expect(err.Error()).To(ContainSubstring("'include_apps' must not be null"))
Expect(err.Error()).To(ContainSubstring("'include_detect' must not be null"))
Expand Down Expand Up @@ -500,6 +504,7 @@ var _ = Describe("Config", func() {
testCfg.RBuildpackName = ptrToString("r_buildpack_override")
testCfg.RubyBuildpackName = ptrToString("ruby_buildpack_override")
testCfg.StaticFileBuildpackName = ptrToString("staticfile_buildpack_override")
testCfg.PythonBuildpackName = ptrToString("python_buildpack_override")

// These values are set so as not to trigger validation errors associated with the overrides provided above
testCfg.PrivateDockerRegistryImage = ptrToString("avoid-validation-errors-by-setting-dummy-value")
Expand Down Expand Up @@ -563,6 +568,7 @@ var _ = Describe("Config", func() {
Expect(config.GetRBuildpackName()).To(Equal("r_buildpack_override"))
Expect(config.GetRubyBuildpackName()).To(Equal("ruby_buildpack_override"))
Expect(config.GetStaticFileBuildpackName()).To(Equal("staticfile_buildpack_override"))
Expect(config.GetPythonBuildpackName()).To(Equal("python_buildpack_override"))
})
})

Expand Down

0 comments on commit a55e671

Please sign in to comment.