Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not enforce presence of CNB_STACK_ID #284

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ func Build(builder Builder, options ...Option) {
logger.Debugf("Buildpack Plan: %+v", ctx.Plan)

if ctx.StackID, ok = os.LookupEnv("CNB_STACK_ID"); !ok {
config.exitHandler.Error(fmt.Errorf("CNB_STACK_ID not set"))
return
logger.Debug("CNB_STACK_ID not set")
} else {
logger.Debugf("Stack: %s", ctx.StackID)
}
logger.Debugf("Stack: %s", ctx.StackID)

result, err := builder.Build(ctx)
if err != nil {
Expand Down
13 changes: 0 additions & 13 deletions build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,6 @@ version = "1.1.1"
Expect(exitHandler.Calls[0].Arguments.Get(0)).To(MatchError("expected 3 arguments and received 0"))
})

it("doesn't receive CNB_STACK_ID", func() {
Expect(os.Unsetenv("CNB_STACK_ID")).To(Succeed())
builder.On("Build", mock.Anything).Return(libcnb.NewBuildResult(), nil)

libcnb.Build(builder,
libcnb.WithBOMLabel(true),
libcnb.WithArguments([]string{commandPath, layersPath, platformPath, buildpackPlanPath}),
libcnb.WithExitHandler(exitHandler),
)

Expect(exitHandler.Calls[0].Arguments.Get(0)).To(MatchError("CNB_STACK_ID not set"))
})

context("when BP API >= 0.8", func() {
it.Before(func() {
Expect(os.WriteFile(filepath.Join(buildpackPath, "buildpack.toml"),
Expand Down
6 changes: 3 additions & 3 deletions detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ func Detect(detector Detector, options ...Option) {
logger.Debugf("Platform Environment: %s", ctx.Platform.Environment)

if ctx.StackID, ok = os.LookupEnv("CNB_STACK_ID"); !ok {
config.exitHandler.Error(fmt.Errorf("CNB_STACK_ID not set"))
return
logger.Debug("CNB_STACK_ID not set")
} else {
logger.Debugf("Stack: %s", ctx.StackID)
}
logger.Debugf("Stack: %s", ctx.StackID)

result, err := detector.Detect(ctx)
if err != nil {
Expand Down
12 changes: 0 additions & 12 deletions detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,6 @@ version = "1.1.1"
Expect(exitHandler.Calls[0].Arguments.Get(0)).To(MatchError("expected 2 arguments and received 0"))
})

it("doesn't receive CNB_STACK_ID", func() {
Expect(os.Unsetenv("CNB_STACK_ID")).To(Succeed())
detector.On("Detect", mock.Anything).Return(libcnb.DetectResult{}, nil)

libcnb.Detect(detector,
libcnb.WithArguments([]string{commandPath, platformPath, buildPlanPath}),
libcnb.WithExitHandler(exitHandler),
)

Expect(exitHandler.Calls[0].Arguments.Get(0)).To(MatchError("CNB_STACK_ID not set"))
})

context("errors if required env vars are not set for buildpack API >=0.8", func() {
for _, e := range []string{"CNB_PLATFORM_DIR", "CNB_BUILD_PLAN_PATH"} {
// We need to do this assignment because of the way that spec binds variables
Expand Down
Loading