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

Dockerfiles phase 1 (generate changes) #869

Merged
merged 9 commits into from
Jun 28, 2022

Conversation

natalieparellano
Copy link
Member

@natalieparellano natalieparellano commented Jun 15, 2022

Edit: resolved the TODOs I think.

Together with #860 this should close out #849.

@natalieparellano natalieparellano changed the title Dockerfiles phase 1 generate Dockerfiles phase 1 (generate changes) Jun 15, 2022
@natalieparellano
Copy link
Member Author

natalieparellano commented Jun 15, 2022

Apologies in advance for the huge diff - this is built off of #867. If/when that is merged, the diff should be smaller ...but still huge.

Edit: re-pointing the branch for now.

@natalieparellano natalieparellano changed the base branch from main to refactor/move-logger June 15, 2022 17:37
Logger: &log.Logger{Handler: logHandler},
}
when("#Build", func() {
when("env", func() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was getting a little unwieldy, hence the huge diff. I'll add some comments to try to make it more understandable.

buildpack/files.go Outdated Show resolved Hide resolved
@natalieparellano
Copy link
Member Author

TODO: need to gate this on experimental features enabled

Generate changes to support Dockerfiles feature

Signed-off-by: Natalie Arellano <[email protected]>
Mainly: the creation of a group-extensions field in group.toml

Signed-off-by: Natalie Arellano <[email protected]>
@natalieparellano natalieparellano marked this pull request as ready for review June 21, 2022 20:19
@natalieparellano natalieparellano requested a review from a team as a code owner June 21, 2022 20:19
Signed-off-by: Natalie Arellano <[email protected]>
Comment on lines +842 to +887
when("for extension", func() {
it.Before(func() {
h.SkipIf(t, kind == buildpack.KindBuildpack, "")
})

when("dockerfiles", func() {
it("includes run.Dockerfile", func() {
h.Mkfile(t,
"",
filepath.Join(appDir, "run.Dockerfile-A-v1"),
)

br, err := descriptor.Build(buildpack.Plan{}, config, mockEnv)
h.AssertNil(t, err)

h.AssertEq(t, br.Dockerfiles[0].ExtensionID, "A")
h.AssertEq(t, br.Dockerfiles[0].Kind, buildpack.DockerfileKindRun)
h.AssertEq(t, br.Dockerfiles[0].Path, filepath.Join(layersDir, "A", "run.Dockerfile"))
})
})

when("/bin/build is missing", func() {
it.Before(func() {
descriptor.Extension.ID = "B"
descriptor.Dir = filepath.Join(storeDir, "B", "v1")
})

it("treats the extension root as a pre-populated output directory", func() {
bpPlan := buildpack.Plan{
Entries: []buildpack.Require{
{Name: "some-dep"},
{Name: "some-other-dep"},
{Name: "some-unmet-dep"},
},
}

br, err := descriptor.Build(bpPlan, config, mockEnv)
h.AssertNil(t, err)

t.Log("processes build.toml")
h.AssertEq(t, br.MetRequires, []string{"some-dep", "some-other-dep"})
t.Log("processes run.Dockerfile")
h.AssertEq(t, br.Dockerfiles[0].ExtensionID, "B")
h.AssertEq(t, br.Dockerfiles[0].Kind, buildpack.DockerfileKindRun)
h.AssertEq(t, br.Dockerfiles[0].Path, filepath.Join(descriptor.Dir, "run.Dockerfile"))
})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most relevant test

Comment on lines +153 to +167
if kind == buildpack.KindExtension {
t.Log("sets CNB_OUTPUT_DIR")
actual = h.Rdfile(t, filepath.Join(appDir, "build-env-cnb-output-dir-A-v1.clear"))
h.AssertEq(t, actual, filepath.Join(layersDir, "A"))
t.Log("does not set CNB_LAYERS_DIR")
actual = h.Rdfile(t, filepath.Join(appDir, "build-env-cnb-layers-dir-A-v1.clear"))
h.AssertEq(t, isUnset(actual), true)
} else {
t.Log("sets CNB_LAYERS_DIR")
actual = h.Rdfile(t, filepath.Join(appDir, "build-env-cnb-layers-dir-A-v1.clear"))
h.AssertEq(t, actual, filepath.Join(layersDir, "A"))
t.Log("does not set CNB_OUTPUT_DIR")
actual = h.Rdfile(t, filepath.Join(appDir, "build-env-cnb-output-dir-A-v1.clear"))
h.AssertEq(t, isUnset(actual), true)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also relevant

detector.go Outdated Show resolved Hide resolved
handlers.go Outdated Show resolved Hide resolved
cmd/flags.go Outdated Show resolved Hide resolved
cmd/flags.go Outdated Show resolved Hide resolved
cmd/flags.go Outdated Show resolved Hide resolved
Base automatically changed from refactor/move-logger to main June 24, 2022 17:24
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Copy link
Contributor

@mboldt mboldt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@natalieparellano natalieparellano merged commit ce23c65 into main Jun 28, 2022
@natalieparellano natalieparellano deleted the dockerfiles-phase-1-generate branch June 28, 2022 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants