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

Detector changes for run image extension #1011

Merged
merged 22 commits into from
Mar 8, 2023
Merged

Conversation

natalieparellano
Copy link
Member

@natalieparellano natalieparellano commented Feb 15, 2023

Fixes #996

- 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 <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
…mage.extend = <true or false, default false>

Signed-off-by: Natalie Arellano <[email protected]>
… should fail if the selected base image is not found in run.toml.

Signed-off-by: Natalie Arellano <[email protected]>
@natalieparellano natalieparellano changed the base branch from main to refactor/lifecycle-inputs February 15, 2023 22:22
@natalieparellano
Copy link
Member Author

This is ready for feedback but we can block merging on #994

@natalieparellano natalieparellano marked this pull request as ready for review February 15, 2023 22:29
@natalieparellano natalieparellano requested a review from a team as a code owner February 15, 2023 22:29
Base automatically changed from refactor/lifecycle-inputs to main February 28, 2023 17:01
@natalieparellano
Copy link
Member Author

The exporter acceptance failure is mystifying me...

cli.FlagLayersDir(&d.LayersDir)
cli.FlagPlanPath(&d.PlanPath)
cli.FlagPlatformDir(&d.PlatformDir)
cli.FlagBuildConfigDir(&d.BuildConfigDir)
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated bug, this should only be valid for newer platforms

We pluralize all other list elements

Signed-off-by: Natalie Arellano <[email protected]>
Comment on lines +58 to +87
type TargetMetadata struct {
buildpack.TargetPartial
Distribution *buildpack.DistributionMetadata `json:"distribution,omitempty" toml:"distribution,omitempty"`
}

// Satisfies treats optional fields (ArchVariant and Distributions) as wildcards if empty, returns true if
func (t *TargetMetadata) IsSatisfiedBy(o *buildpack.TargetMetadata) bool {
if t.Arch != o.Arch || t.OS != o.OS {
return false
}
if t.ArchVariant != "" && o.ArchVariant != "" && t.ArchVariant != o.ArchVariant {
return false
}

// if either of the lengths of Distributions are zero, treat it as a wildcard.
if t.Distribution != nil && len(o.Distributions) > 0 {
// this could be more efficient but the lists are probably short...
found := false
for _, odist := range o.Distributions {
if t.Distribution.Name == odist.Name && t.Distribution.Version == odist.Version {
found = true
continue
}
}
if !found {
return false
}
}
return 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.

Copied from further down in the file

generator.go Outdated Show resolved Hide resolved
buildpack/dockerfile.go Outdated Show resolved Hide resolved
@natalieparellano natalieparellano merged commit fa9a11a into main Mar 8, 2023
@natalieparellano natalieparellano deleted the runext/detect-996 branch March 8, 2023 20:02
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.

[RFC #0105] Detector changes for run image extension (Dockerfiles phase 3)
3 participants