-
Notifications
You must be signed in to change notification settings - Fork 294
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
Lifecycle image #1130
Lifecycle image #1130
Changes from all commits
5274f2f
466fd8b
116f500
04c1ce6
2164781
af2820f
2d551a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import ( | |
acceptanceOS "github.com/buildpacks/pack/acceptance/os" | ||
"github.com/buildpacks/pack/internal/blob" | ||
"github.com/buildpacks/pack/internal/builder" | ||
"github.com/buildpacks/pack/internal/config" | ||
"github.com/buildpacks/pack/internal/style" | ||
h "github.com/buildpacks/pack/testhelpers" | ||
) | ||
|
@@ -36,8 +37,10 @@ type AssetManager struct { | |
githubAssetFetcher *GithubAssetFetcher | ||
lifecyclePath string | ||
lifecycleDescriptor builder.LifecycleDescriptor | ||
lifecycleImage string | ||
previousLifecyclePath string | ||
previousLifecycleDescriptor builder.LifecycleDescriptor | ||
previousLifecycleImage string | ||
defaultLifecycleDescriptor builder.LifecycleDescriptor | ||
testObject *testing.T | ||
} | ||
|
@@ -50,8 +53,10 @@ func ConvergedAssetManager(t *testing.T, assert h.AssertionManager, inputConfig | |
convergedPreviousPackPath string | ||
convergedPreviousPackFixturesPaths []string | ||
convergedCurrentLifecyclePath string | ||
convergedCurrentLifecycleImage string | ||
convergedCurrentLifecycleDescriptor builder.LifecycleDescriptor | ||
convergedPreviousLifecyclePath string | ||
convergedPreviousLifecycleImage string | ||
convergedPreviousLifecycleDescriptor builder.LifecycleDescriptor | ||
convergedDefaultLifecycleDescriptor builder.LifecycleDescriptor | ||
) | ||
|
@@ -78,11 +83,11 @@ func ConvergedAssetManager(t *testing.T, assert h.AssertionManager, inputConfig | |
} | ||
|
||
if inputConfig.combinations.requiresCurrentLifecycle() { | ||
convergedCurrentLifecyclePath, convergedCurrentLifecycleDescriptor = assetBuilder.ensureCurrentLifecycle() | ||
convergedCurrentLifecyclePath, convergedCurrentLifecycleImage, convergedCurrentLifecycleDescriptor = assetBuilder.ensureCurrentLifecycle() | ||
} | ||
|
||
if inputConfig.combinations.requiresPreviousLifecycle() { | ||
convergedPreviousLifecyclePath, convergedPreviousLifecycleDescriptor = assetBuilder.ensurePreviousLifecycle() | ||
convergedPreviousLifecyclePath, convergedPreviousLifecycleImage, convergedPreviousLifecycleDescriptor = assetBuilder.ensurePreviousLifecycle() | ||
} | ||
|
||
if inputConfig.combinations.requiresDefaultLifecycle() { | ||
|
@@ -95,8 +100,10 @@ func ConvergedAssetManager(t *testing.T, assert h.AssertionManager, inputConfig | |
previousPackPath: convergedPreviousPackPath, | ||
previousPackFixturesPaths: convergedPreviousPackFixturesPaths, | ||
lifecyclePath: convergedCurrentLifecyclePath, | ||
lifecycleImage: convergedCurrentLifecycleImage, | ||
lifecycleDescriptor: convergedCurrentLifecycleDescriptor, | ||
previousLifecyclePath: convergedPreviousLifecyclePath, | ||
previousLifecycleImage: convergedPreviousLifecycleImage, | ||
previousLifecycleDescriptor: convergedPreviousLifecycleDescriptor, | ||
defaultLifecycleDescriptor: convergedDefaultLifecycleDescriptor, | ||
testObject: t, | ||
|
@@ -152,6 +159,22 @@ func (a AssetManager) LifecycleDescriptor(kind ComboValue) builder.LifecycleDesc | |
return builder.LifecycleDescriptor{} // Unreachable | ||
} | ||
|
||
func (a AssetManager) LifecycleImage(kind ComboValue) string { | ||
a.testObject.Helper() | ||
|
||
switch kind { | ||
case Current: | ||
natalieparellano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return a.lifecycleImage | ||
case Previous: | ||
natalieparellano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return a.previousLifecycleImage | ||
case DefaultKind: | ||
return fmt.Sprintf("%s:%s", config.DefaultLifecycleImageRepo, a.defaultLifecycleDescriptor.Info.Version) | ||
natalieparellano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
a.testObject.Fatalf("lifecycle kind must be previous, current or default was %s", kind) | ||
return "" // Unreachable | ||
} | ||
|
||
type assetManagerBuilder struct { | ||
testObject *testing.T | ||
assert h.AssertionManager | ||
|
@@ -235,7 +258,7 @@ func (b assetManagerBuilder) ensurePreviousPackFixtures() string { | |
return fixturesDir | ||
} | ||
|
||
func (b assetManagerBuilder) ensureCurrentLifecycle() (string, builder.LifecycleDescriptor) { | ||
func (b assetManagerBuilder) ensureCurrentLifecycle() (string, string, builder.LifecycleDescriptor) { | ||
b.testObject.Helper() | ||
|
||
lifecyclePath := b.inputConfig.lifecyclePath | ||
|
@@ -255,10 +278,18 @@ func (b assetManagerBuilder) ensureCurrentLifecycle() (string, builder.Lifecycle | |
lifecycle, err := builder.NewLifecycle(blob.NewBlob(lifecyclePath)) | ||
b.assert.Nil(err) | ||
|
||
return lifecyclePath, lifecycle.Descriptor() | ||
lifecycleImage := b.inputConfig.lifecycleImage | ||
|
||
if lifecycleImage == "" { | ||
lifecycleImage = fmt.Sprintf("%s:%s", config.DefaultLifecycleImageRepo, lifecycle.Descriptor().Info.Version) | ||
|
||
b.testObject.Logf("using %s for current lifecycle image", lifecycleImage) | ||
} | ||
|
||
return lifecyclePath, lifecycleImage, lifecycle.Descriptor() | ||
} | ||
|
||
func (b assetManagerBuilder) ensurePreviousLifecycle() (string, builder.LifecycleDescriptor) { | ||
func (b assetManagerBuilder) ensurePreviousLifecycle() (string, string, builder.LifecycleDescriptor) { | ||
b.testObject.Helper() | ||
|
||
previousLifecyclePath := b.inputConfig.previousLifecyclePath | ||
|
@@ -278,7 +309,15 @@ func (b assetManagerBuilder) ensurePreviousLifecycle() (string, builder.Lifecycl | |
lifecycle, err := builder.NewLifecycle(blob.NewBlob(previousLifecyclePath)) | ||
b.assert.Nil(err) | ||
|
||
return previousLifecyclePath, lifecycle.Descriptor() | ||
previousLifecycleImage := b.inputConfig.previousLifecycleImage | ||
|
||
if previousLifecycleImage == "" { | ||
previousLifecycleImage = fmt.Sprintf("%s:%s", config.DefaultLifecycleImageRepo, lifecycle.Descriptor().Info.Version) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. opt.semgrep.sprintf-host-port: Use (at-me in a reply with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Muse-Dev ignore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've recorded this as ignored for this pull request. If you change your mind, just comment |
||
|
||
b.testObject.Logf("using %s for previous lifecycle image", previousLifecycleImage) | ||
} | ||
|
||
return previousLifecyclePath, previousLifecycleImage, lifecycle.Descriptor() | ||
} | ||
|
||
func (b assetManagerBuilder) downloadLifecycle(version string) string { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,16 @@ import ( | |
) | ||
|
||
const ( | ||
envPackPath = "PACK_PATH" | ||
envPreviousPackPath = "PREVIOUS_PACK_PATH" | ||
envPreviousPackFixturesPath = "PREVIOUS_PACK_FIXTURES_PATH" | ||
envLifecyclePath = "LIFECYCLE_PATH" | ||
envPreviousLifecyclePath = "PREVIOUS_LIFECYCLE_PATH" | ||
envGitHubToken = "GITHUB_TOKEN" | ||
Comment on lines
-16
to
-21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorted again... |
||
envAcceptanceSuiteConfig = "ACCEPTANCE_SUITE_CONFIG" | ||
envCompilePackWithVersion = "COMPILE_PACK_WITH_VERSION" | ||
envGitHubToken = "GITHUB_TOKEN" | ||
envLifecycleImage = "LIFECYCLE_IMAGE" | ||
envLifecyclePath = "LIFECYCLE_PATH" | ||
envPackPath = "PACK_PATH" | ||
envPreviousLifecycleImage = "PREVIOUS_LIFECYCLE_IMAGE" | ||
envPreviousLifecyclePath = "PREVIOUS_LIFECYCLE_PATH" | ||
envPreviousPackFixturesPath = "PREVIOUS_PACK_FIXTURES_PATH" | ||
envPreviousPackPath = "PREVIOUS_PACK_PATH" | ||
) | ||
|
||
type InputConfigurationManager struct { | ||
|
@@ -29,6 +31,8 @@ type InputConfigurationManager struct { | |
previousPackFixturesPath string | ||
lifecyclePath string | ||
previousLifecyclePath string | ||
lifecycleImage string | ||
previousLifecycleImage string | ||
compilePackWithVersion string | ||
githubToken string | ||
combinations ComboSet | ||
|
@@ -40,8 +44,6 @@ func NewInputConfigurationManager() (InputConfigurationManager, error) { | |
previousPackFixturesPath := os.Getenv(envPreviousPackFixturesPath) | ||
lifecyclePath := os.Getenv(envLifecyclePath) | ||
previousLifecyclePath := os.Getenv(envPreviousLifecyclePath) | ||
compilePackWithVersion := os.Getenv(envCompilePackWithVersion) | ||
githubToken := os.Getenv(envGitHubToken) | ||
|
||
err := resolveAbsolutePaths(&packPath, &previousPackPath, &previousPackFixturesPath, &lifecyclePath, &previousLifecyclePath) | ||
if err != nil { | ||
|
@@ -69,8 +71,10 @@ func NewInputConfigurationManager() (InputConfigurationManager, error) { | |
previousPackFixturesPath: previousPackFixturesPath, | ||
lifecyclePath: lifecyclePath, | ||
previousLifecyclePath: previousLifecyclePath, | ||
compilePackWithVersion: compilePackWithVersion, | ||
githubToken: githubToken, | ||
Comment on lines
-72
to
-73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems fine to inline these. |
||
lifecycleImage: os.Getenv(envLifecycleImage), | ||
previousLifecycleImage: os.Getenv(envPreviousLifecycleImage), | ||
compilePackWithVersion: os.Getenv(envCompilePackWithVersion), | ||
githubToken: os.Getenv(envGitHubToken), | ||
combinations: combos, | ||
}, nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorted alphabetically...