Skip to content

Commit

Permalink
Restorer changes for run image extension (#1014)
Browse files Browse the repository at this point in the history
* Make a single constructor for lifecycle inputs

- The logic to update the default path for TOML files was repeated across phases
- In general it is safe to provide default values for inputs that might not be relevant to the current phase,
  as these will be ignored when constructing a new service for the phase;
  e.g., platform.LifecycleInputs.OrderPath will be ignored when constructing a lifecycle.Exporter
- As more inputs are shared across phases (e.g., analyzed.toml is now an input to the detect phase),
  duplicating the logic for providing default values is becoming more cumbersome

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Read values from environment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Buildpack API: run.Dockerfiles are allowed instructions on versions >= 0.10

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the detector accepts a new -run flag

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Move responsibility for validating Dockerfiles into the buildpack package

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When verifying Dockerfiles, return the new base image name if necessary

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* When determining the new runtime base image, use criteria outlined in the platform spec

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the schema of analyzed.toml is updated to include run-image.extend = <true or false, default false>

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* TESTME: Update analyzed.toml with new run image if needed

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* If extensions are used to switch the runtime base image, the detector should fail if the selected base image is not found in run.toml.

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add fixture to test re-writing of analyzed.toml

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Move updating analyzed.toml into lifecycle package for easier testing

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Platform API: the restorer will update analyzed.toml with:
- digest ref for run image
- target data for run image

Additionally the restorer will download the run image manifest & config when extend is true

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update acceptance/extender_test.go

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix merge and restore selective package

imgutil/layout/sparse modifies the image media types which we don't want

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Update analyzed.toml with digest reference or target data if needed

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Don't redefine -layers

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Test organization and remove the requirement that we're exporting to a registry to use run image extensions

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Test that we don't update target data for older platforms

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Remove target partial and use helper function

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Bump imgutil

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix acceptance

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Use imgutil/sparse package instead of internal/selective package

We'll be able to fully remove internal/selective
when we update tests for the extender as part of #998

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Don't try to pull a builder image if it wasn't specified

Ensure we write a digest reference to analyzed.toml

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Fix lint

Signed-off-by: Natalie Arellano <narellano@vmware.com>

* Add and update comment

Signed-off-by: Natalie Arellano <narellano@vmware.com>

---------

Signed-off-by: Natalie Arellano <narellano@vmware.com>
  • Loading branch information
natalieparellano authored Mar 28, 2023
1 parent 1299eb8 commit 47594c2
Show file tree
Hide file tree
Showing 21 changed files with 408 additions and 227 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
.vscode
acceptance/testdata/*/**/container/cnb/lifecycle/*
acceptance/testdata/*/**/container/docker-config/*
acceptance/testdata/restorer/container/layers/*analyzed.toml
acceptance/testdata/exporter/container/layers/*analyzed.toml
acceptance/testdata/exporter/container/other_layers/*analyzed.toml
55 changes: 33 additions & 22 deletions acceptance/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,30 +354,41 @@ func testExporterFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
}
}

// This helper function exists because we expect the run image in analyzed.toml to contain the registry IP and port,
// which aren't known until we start the test.
func updateAnalyzedTOMLFixturesWithRegRepoName(t *testing.T, phaseTest *PhaseTest) {
placeHolderPath := filepath.Join("testdata", "exporter", "container", "layers", "analyzed.toml.placeholder")
analyzedMD := assertAnalyzedMetadata(t, placeHolderPath)
analyzedMD.RunImage = &platform.RunImage{Reference: phaseTest.targetRegistry.fixtures.ReadOnlyRunImage}
encoding.WriteTOML(strings.TrimSuffix(placeHolderPath, ".placeholder"), analyzedMD)

placeHolderPath = filepath.Join("testdata", "exporter", "container", "layers", "some-analyzed.toml.placeholder")
analyzedMD = assertAnalyzedMetadata(t, placeHolderPath)
analyzedMD.PreviousImage = &platform.ImageIdentifier{Reference: phaseTest.targetRegistry.fixtures.SomeAppImage}
analyzedMD.RunImage = &platform.RunImage{Reference: phaseTest.targetRegistry.fixtures.ReadOnlyRunImage}
encoding.WriteTOML(strings.TrimSuffix(placeHolderPath, ".placeholder"), analyzedMD)

placeHolderPath = filepath.Join("testdata", "exporter", "container", "other_layers", "analyzed.toml.placeholder")
analyzedMD = assertAnalyzedMetadata(t, placeHolderPath)
analyzedMD.RunImage = &platform.RunImage{Reference: phaseTest.targetRegistry.fixtures.ReadOnlyRunImage}
encoding.WriteTOML(strings.TrimSuffix(placeHolderPath, ".placeholder"), analyzedMD)

placeHolderPath = filepath.Join("testdata", "exporter", "container", "layers", "layout-analyzed.toml.placeholder")
analyzedMD = assertAnalyzedMetadata(t, placeHolderPath)
// Values from image acceptance/testdata/exporter/container/layout-repo in OCI layout format
analyzedMD.RunImage = &platform.RunImage{
Reference: "/layout-repo/index.docker.io/library/busybox/latest@sha256:445c45cc89fdeb64b915b77f042e74ab580559b8d0d5ef6950be1c0265834c33",
regPlaceholders := []string{
filepath.Join(phaseTest.testImageDockerContext, "container", "layers", "analyzed.toml.placeholder"),
filepath.Join(phaseTest.testImageDockerContext, "container", "layers", "some-analyzed.toml.placeholder"),
filepath.Join(phaseTest.testImageDockerContext, "container", "layers", "some-extend-false-analyzed.toml.placeholder"),
filepath.Join(phaseTest.testImageDockerContext, "container", "layers", "some-extend-true-analyzed.toml.placeholder"),
filepath.Join(phaseTest.testImageDockerContext, "container", "other_layers", "analyzed.toml.placeholder"),
}
layoutPlaceholders := []string{
filepath.Join(phaseTest.testImageDockerContext, "container", "layers", "layout-analyzed.toml.placeholder"),
}

for _, pPath := range regPlaceholders {
if _, err := os.Stat(pPath); os.IsNotExist(err) {
continue
}
analyzedMD := assertAnalyzedMetadata(t, pPath)
if analyzedMD.RunImage != nil {
analyzedMD.RunImage.Reference = phaseTest.targetRegistry.fixtures.ReadOnlyRunImage // don't override extend
}
encoding.WriteTOML(strings.TrimSuffix(pPath, ".placeholder"), analyzedMD)
}
for _, pPath := range layoutPlaceholders {
if _, err := os.Stat(pPath); os.IsNotExist(err) {
continue
}
analyzedMD := assertAnalyzedMetadata(t, pPath)
if analyzedMD.RunImage != nil {
// Values from image acceptance/testdata/exporter/container/layout-repo in OCI layout format
analyzedMD.RunImage = &platform.RunImage{Reference: "/layout-repo/index.docker.io/library/busybox/latest@sha256:445c45cc89fdeb64b915b77f042e74ab580559b8d0d5ef6950be1c0265834c33"}
}
encoding.WriteTOML(strings.TrimSuffix(pPath, ".placeholder"), analyzedMD)
}
encoding.WriteTOML(strings.TrimSuffix(placeHolderPath, ".placeholder"), analyzedMD)
}

func calculateEmptyLayerSha(t *testing.T) string {
Expand Down
90 changes: 82 additions & 8 deletions acceptance/restorer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import (
"testing"
"time"

"github.com/google/go-containerregistry/pkg/name"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"

"github.com/buildpacks/lifecycle"
"github.com/buildpacks/lifecycle/api"
"github.com/buildpacks/lifecycle/cmd"
h "github.com/buildpacks/lifecycle/testhelpers"
)

Expand All @@ -38,7 +40,7 @@ func TestRestorer(t *testing.T) {

testImageDockerContext := filepath.Join("testdata", "restorer")
restoreTest = NewPhaseTest(t, "restorer", testImageDockerContext)
restoreTest.Start(t)
restoreTest.Start(t, updateAnalyzedTOMLFixturesWithRegRepoName)
defer restoreTest.Stop(t)

restoreImage = restoreTest.testImageRef
Expand Down Expand Up @@ -80,7 +82,7 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
})
})

when("called with -analyzed", func() {
when("called with -analyzed (on older platforms)", func() {
it("errors", func() {
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 supports -analyzed flag")
command := exec.Command("docker", "run", "--rm", restoreImage, "-analyzed some-file-location")
Expand All @@ -91,7 +93,7 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
})
})

when("called with -skip-layers", func() {
when("called with -skip-layers (on older platforms)", func() {
it("errors", func() {
h.SkipIf(t, api.MustParse(platformAPI).AtLeast("0.7"), "Platform API >= 0.7 supports -skip-layers flag")
command := exec.Command("docker", "run", "--rm", restoreImage, "-skip-layers true")
Expand Down Expand Up @@ -188,9 +190,9 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
})
})

when("using kaniko cache", func() {
it("accepts -build-image", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.10"), "Platform API < 0.10 does not use kaniko")
when("restoring builder image metadata for extensions", func() {
it("accepts -build-image and saves the metadata to /kaniko/cache", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.10"), "Platform API < 0.10 does not restore builder image metadata")
h.DockerRunAndCopy(t,
containerName,
copyDir,
Expand All @@ -204,14 +206,86 @@ func testRestorerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
h.WithArgs("-build-image", restoreRegFixtures.SomeCacheImage), // some-cache-image simulates a builder image in a registry
)
t.Log("records builder image digest in analyzed.toml")
analyzedMD, err := lifecycle.Config.ReadAnalyzed(filepath.Join(copyDir, "layers", "analyzed.toml"), nil)
analyzedMD, err := lifecycle.Config.ReadAnalyzed(filepath.Join(copyDir, "layers", "analyzed.toml"), cmd.DefaultLogger)
h.AssertNil(t, err)
h.AssertStringContains(t, analyzedMD.BuildImage.Reference, restoreRegFixtures.SomeCacheImage+"@sha256:")
t.Log("writes builder manifest and config to the kaniko cache")
ref, err := name.ParseReference(analyzedMD.BuildImage.Reference)
h.AssertNil(t, err)
fis, err := os.ReadDir(filepath.Join(copyDir, "kaniko", "cache", "base"))
h.AssertNil(t, err)
h.AssertEq(t, len(fis), 1)
h.AssertPathExists(t, filepath.Join(copyDir, "kaniko", "cache", "base", fis[0].Name(), "oci-layout"))
h.AssertPathExists(t, filepath.Join(copyDir, "kaniko", "cache", "base", ref.Identifier(), "oci-layout"))
})
})

when("restoring run image metadata for extensions", func() {
it("saves metadata to /kaniko/cache", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.12"), "Platform API < 0.12 does not restore run image metadata")
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/",
restoreImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "DOCKER_CONFIG=/docker-config",
"--network", restoreRegNetwork,
),
h.WithArgs(
"-analyzed", "/layers/some-extend-true-analyzed.toml",
"-log-level", "debug",
),
)
t.Log("updates run image reference in analyzed.toml to include digest and target data")
analyzedMD, err := lifecycle.Config.ReadAnalyzed(filepath.Join(copyDir, "layers", "some-extend-true-analyzed.toml"), cmd.DefaultLogger)
h.AssertNil(t, err)
h.AssertStringContains(t, analyzedMD.RunImage.Reference, restoreRegFixtures.ReadOnlyRunImage+"@sha256:")
h.AssertEq(t, analyzedMD.RunImage.TargetMetadata.OS, "linux")
t.Log("writes run image manifest and config to the kaniko cache")
ref, err := name.ParseReference(analyzedMD.RunImage.Reference)
h.AssertNil(t, err)
fis, err := os.ReadDir(filepath.Join(copyDir, "kaniko", "cache", "base"))
h.AssertNil(t, err)
h.AssertEq(t, len(fis), 1)
h.AssertPathExists(t, filepath.Join(copyDir, "kaniko", "cache", "base", ref.Identifier(), "oci-layout"))
})
})

when("target data", func() {
it("updates run image reference in analyzed.toml to include digest and target data on newer platforms", func() {
h.SkipIf(t, api.MustParse(platformAPI).LessThan("0.7"), "Platform API < 0.7 does not support -analyzed flag")
h.DockerRunAndCopy(t,
containerName,
copyDir,
"/",
restoreImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--env", "DOCKER_CONFIG=/docker-config",
"--network", restoreRegNetwork,
),
h.WithArgs(
"-analyzed", "/layers/some-extend-false-analyzed.toml",
"-log-level", "debug",
),
)
if api.MustParse(platformAPI).AtLeast("0.12") {
t.Log("updates run image reference in analyzed.toml to include digest and target data")
analyzedMD, err := lifecycle.Config.ReadAnalyzed(filepath.Join(copyDir, "layers", "some-extend-false-analyzed.toml"), cmd.DefaultLogger)
h.AssertNil(t, err)
h.AssertStringContains(t, analyzedMD.RunImage.Reference, restoreRegFixtures.ReadOnlyRunImage+"@sha256:")
h.AssertEq(t, analyzedMD.RunImage.TargetMetadata.OS, "linux")
t.Log("does not write run image manifest and config to the kaniko cache")
fis, err := os.ReadDir(filepath.Join(copyDir, "kaniko"))
h.AssertNil(t, err)
h.AssertEq(t, len(fis), 1) // .gitkeep
} else {
t.Log("doesn't update analyzed.toml")
analyzedMD, err := lifecycle.Config.ReadAnalyzed(filepath.Join(copyDir, "layers", "some-extend-false-analyzed.toml"), cmd.DefaultLogger)
h.AssertNil(t, err)
h.AssertNil(t, analyzedMD.RunImage.TargetMetadata)
}
})
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[image]
reference = "some-ref"
reference = "some-previous-image-ref"

[[metadata.buildpacks]]
key = "some-buildpack-id"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run-image]
reference = "REPLACE"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run-image]
reference = "REPLACE"
extend = true
2 changes: 1 addition & 1 deletion analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (a *Analyzer) Analyze() (platform.AnalyzedMetadata, error) {

return platform.AnalyzedMetadata{
PreviousImage: &platform.ImageIdentifier{Reference: previousImageRef},
RunImage: &platform.RunImage{Reference: runImageRef, Target: atm},
RunImage: &platform.RunImage{Reference: runImageRef, TargetMetadata: atm},
Metadata: appMeta,
}, nil
}
Expand Down
18 changes: 9 additions & 9 deletions analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,16 +682,16 @@ func testAnalyzer(platformAPI string) func(t *testing.T, when spec.G, it spec.S)
md, err := analyzer.Analyze()
h.AssertNil(t, err)
if api.MustParse(platformAPI).LessThan("0.12") {
h.AssertNil(t, md.RunImage.Target)
h.AssertNil(t, md.RunImage.TargetMetadata)
} else {
h.AssertNotNil(t, md.RunImage.Target)
h.AssertEq(t, md.RunImage.Target.Arch, "Pentium")
h.AssertEq(t, md.RunImage.Target.ArchVariant, "MMX")
h.AssertEq(t, md.RunImage.Target.OS, "windows")
h.AssertEq(t, md.RunImage.Target.ID, "id software")
h.AssertNotNil(t, md.RunImage.Target.Distribution)
h.AssertEq(t, md.RunImage.Target.Distribution.Name, "moobuntu")
h.AssertEq(t, md.RunImage.Target.Distribution.Version, "Helpful Holstein")
h.AssertNotNil(t, md.RunImage.TargetMetadata)
h.AssertEq(t, md.RunImage.TargetMetadata.Arch, "Pentium")
h.AssertEq(t, md.RunImage.TargetMetadata.ArchVariant, "MMX")
h.AssertEq(t, md.RunImage.TargetMetadata.OS, "windows")
h.AssertEq(t, md.RunImage.TargetMetadata.ID, "id software")
h.AssertNotNil(t, md.RunImage.TargetMetadata.Distribution)
h.AssertEq(t, md.RunImage.TargetMetadata.Distribution.Name, "moobuntu")
h.AssertEq(t, md.RunImage.TargetMetadata.Distribution.Version, "Helpful Holstein")
}
})
})
Expand Down
22 changes: 9 additions & 13 deletions buildpack/bp_descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@ type StackMetadata struct {
ID string `toml:"id"`
}

type TargetPartial struct {
Arch string `json:"arch" toml:"arch"`
ArchVariant string `json:"arch-variant" toml:"arch-variant"`
OS string `json:"os" toml:"os"`
}

type TargetMetadata struct {
TargetPartial
Distributions []DistributionMetadata `json:"distributions" toml:"distributions"`
OS string `json:"os" toml:"os"`
Arch string `json:"arch" toml:"arch"`
ArchVariant string `json:"arch-variant" toml:"arch-variant"`
Distributions []OSDistribution `json:"distributions" toml:"distributions"`
}

type DistributionMetadata struct {
type OSDistribution struct {
Name string `json:"name" toml:"name"`
Version string `json:"version" toml:"version"`
}
Expand Down Expand Up @@ -66,9 +62,9 @@ func ReadBpDescriptor(path string) (*BpDescriptor, error) {
if len(descriptor.Targets) == 0 {
for _, stack := range descriptor.Stacks {
if stack.ID == "io.buildpacks.stacks.bionic" {
descriptor.Targets = append(descriptor.Targets, TargetMetadata{TargetPartial: TargetPartial{OS: "linux", Arch: "amd64"}, Distributions: []DistributionMetadata{{Name: "ubuntu", Version: "18.04"}}})
descriptor.Targets = append(descriptor.Targets, TargetMetadata{OS: "linux", Arch: "amd64", Distributions: []OSDistribution{{Name: "ubuntu", Version: "18.04"}}})
} else if stack.ID == "*" {
descriptor.Targets = append(descriptor.Targets, TargetMetadata{TargetPartial: TargetPartial{OS: "*", Arch: "*"}, Distributions: []DistributionMetadata{}})
descriptor.Targets = append(descriptor.Targets, TargetMetadata{OS: "*", Arch: "*", Distributions: []OSDistribution{}})
}
}
}
Expand All @@ -84,11 +80,11 @@ func ReadBpDescriptor(path string) (*BpDescriptor, error) {
bf := binFiles[len(binFiles)-i-1] // we're iterating backwards b/c os.ReadDir sorts "build.exe" after "build" but we want to preferentially detect windows first.
fname := bf.Name()
if fname == "build.exe" || fname == "build.bat" {
descriptor.Targets = append(descriptor.Targets, TargetMetadata{TargetPartial: TargetPartial{OS: "windows", Arch: "*"}})
descriptor.Targets = append(descriptor.Targets, TargetMetadata{OS: "windows", Arch: "*"})
break
}
if fname == "build" {
descriptor.Targets = append(descriptor.Targets, TargetMetadata{TargetPartial: TargetPartial{OS: "linux", Arch: "*"}})
descriptor.Targets = append(descriptor.Targets, TargetMetadata{OS: "linux", Arch: "*"})
}
}
}
Expand Down
29 changes: 14 additions & 15 deletions buildpack/dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ func testDockerfile(t *testing.T, when spec.G, it spec.S) {
})

when("verifying dockerfiles", func() {
validCases := []string{
`
validCases := []string{`
ARG base_image=0
FROM ${base_image}
Expand Down Expand Up @@ -132,23 +131,23 @@ RUN echo "this statement is never cached"
h.AssertEq(t, len(logHandler.Entries), 0)
}
})
})

when("valid, but violates SHOULD directives in spec", func() {
it("succeeds with warning", func() {
preamble := `
when("violates SHOULD directives in spec", func() {
it("succeeds with warning", func() {
preamble := `
ARG base_image=0
FROM ${base_image}
`
for i, tc := range warnCases {
dockerfilePath := filepath.Join(tmpDir, fmt.Sprintf("Dockerfile%d", i))
h.AssertNil(t, os.WriteFile(dockerfilePath, []byte(preamble+tc.dockerfileContent), 0600))
logHandler = memory.New()
logger = &log.Logger{Handler: logHandler}
err := buildpack.VerifyBuildDockerfile(dockerfilePath, logger)
h.AssertNil(t, err)
assertLogEntry(t, logHandler, "build.Dockerfile "+tc.expectedWarning)
}
for i, tc := range warnCases {
dockerfilePath := filepath.Join(tmpDir, fmt.Sprintf("Dockerfile%d", i))
h.AssertNil(t, os.WriteFile(dockerfilePath, []byte(preamble+tc.dockerfileContent), 0600))
logHandler = memory.New()
logger = &log.Logger{Handler: logHandler}
err := buildpack.VerifyBuildDockerfile(dockerfilePath, logger)
h.AssertNil(t, err)
assertLogEntry(t, logHandler, "build.Dockerfile "+tc.expectedWarning)
}
})
})
})

Expand Down
4 changes: 2 additions & 2 deletions buildpack/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ func findDockerfileFor(d ExtDescriptor, extOutputDir string, kind string, logger
return DockerfileInfo{}, false, nil
}

newBase, err := verifyDockerfileFor(d, dockerfilePath, kind, logger)
newBase, err := verifyDockerfileFor(dockerfilePath, kind, logger)
if err != nil {
return DockerfileInfo{}, true, fmt.Errorf("failed to parse %s.Dockerfile for extension %s: %w", kind, d.Extension.ID, err)
}
return DockerfileInfo{ExtensionID: d.Extension.ID, Kind: kind, Path: dockerfilePath, NewBase: newBase}, true, nil
}

func verifyDockerfileFor(d ExtDescriptor, path string, kind string, logger log.Logger) (string, error) {
func verifyDockerfileFor(path string, kind string, logger log.Logger) (string, error) {
switch kind {
case DockerfileKindBuild:
return "", VerifyBuildDockerfile(path, logger)
Expand Down
4 changes: 2 additions & 2 deletions cmd/lifecycle/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ func (e *exportCmd) DefineFlags() {
cli.FlagProcessType(&e.DefaultProcessType)
cli.FlagProjectMetadataPath(&e.ProjectMetadataPath)
cli.FlagReportPath(&e.ReportPath)
cli.FlagRunImage(&e.RunImageRef)
cli.FlagRunImage(&e.RunImageRef) // FIXME: this flag isn't valid on Platform 0.7 and later
cli.FlagStackPath(&e.StackPath)
cli.FlagUID(&e.UID)
cli.FlagUseDaemon(&e.UseDaemon)

cli.DeprecatedFlagRunImage(&e.DeprecatedRunImageRef)
cli.DeprecatedFlagRunImage(&e.DeprecatedRunImageRef) // FIXME: this flag isn't valid on Platform 0.7 and later
}

// Args validates arguments and flags, and fills in default values.
Expand Down
Loading

0 comments on commit 47594c2

Please sign in to comment.