Skip to content

Commit e0b3ac4

Browse files
committed
Merge branch 'fix/file-inclusion' of github.com:rahulgrover99/pack into fix/file-inclusion
2 parents 09cc3ba + ae09b89 commit e0b3ac4

18 files changed

Lines changed: 147 additions & 215 deletions

DEVELOPMENT.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ Some options users can provide to our acceptance tests are:
100100
| ACCEPTANCE_SUITE_CONFIG | A set of configurations for how to run the acceptance tests, describing the version of `pack` used for testing, the version of `pack` used to create the builders used in the test, and the version of `lifecycle` binaries used to test with Github | `[{"pack": "current", "pack_create_builder": "current", "lifecycle": "default"}]'` |
101101
| COMPILE_PACK_WITH_VERSION | Tell `pack` what version to consider itself | `dev` |
102102
| GITHUB_TOKEN | A Github Token, used when downloading `pack` and `lifecycle` releases from Github during the test setup | "" |
103-
| PACK_PATH | Path to a `pack` executable. | A compiled version of the current branch |
104-
| PREVIOUS_PACK_PATH | Path to a `pack` executable, used to test compatibility with n-1 version of `pack` | The most recent release from `pack`'s Github release |
105-
| PREVIOUS_PACK_FIXTURES_PATH | Path to a set of fixtures, used to override the most up-to-date fixtures, in case of changed functionality | `acceptance/testdata/pack_previous_fixtures_overrides` |
103+
| LIFECYCLE_IMAGE | Image reference to be used in untrusted builder workflows | buildpacksio/lifecycle:<lifecycle version> |
106104
| LIFECYCLE_PATH | Path to a `.tgz` file filled with a set of `lifecycle` binaries | The Github release for the default version of lifecycle in `pack` |
105+
| PACK_PATH | Path to a `pack` executable. | A compiled version of the current branch |
106+
| PREVIOUS_LIFECYCLE_IMAGE | Image reference to be used in untrusted builder workflows, used to test compatibility of `pack` with the n-1 version of the `lifecycle` | buildpacksio/lifecycle:<PREVIOUS_LIFECYCLE_PATH lifecycle version>, buildpacksio/lifecycle:<n-1 lifecycle version> |
107107
| PREVIOUS_LIFECYCLE_PATH | Path to a `.tgz` file filled with a set of `lifecycle` binaries, used to test compatibility of `pack` with the n-1 version of the `lifecycle` | The Github release for n-1 release of `lifecycle` |
108+
| PREVIOUS_PACK_FIXTURES_PATH | Path to a set of fixtures, used to override the most up-to-date fixtures, in case of changed functionality | `acceptance/testdata/pack_previous_fixtures_overrides` |
109+
| PREVIOUS_PACK_PATH | Path to a `pack` executable, used to test compatibility with n-1 version of `pack` | The most recent release from `pack`'s Github release |

acceptance/acceptance_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"github.com/buildpacks/pack/acceptance/managers"
3636
pubcfg "github.com/buildpacks/pack/config"
3737
"github.com/buildpacks/pack/internal/cache"
38-
internalConfig "github.com/buildpacks/pack/internal/config"
3938
"github.com/buildpacks/pack/internal/style"
4039
"github.com/buildpacks/pack/pkg/archive"
4140
h "github.com/buildpacks/pack/testhelpers"
@@ -772,6 +771,7 @@ func testAcceptance(
772771
it.Before(func() {
773772
repo = "some-org/" + h.RandString(10)
774773
repoName = registryConfig.RepoName(repo)
774+
pack.JustRunSuccessfully("config", "lifecycle-image", lifecycle.Image())
775775
})
776776

777777
it.After(func() {
@@ -798,14 +798,13 @@ func testAcceptance(
798798
buildpackManager,
799799
runImageMirror,
800800
)
801+
assert.Nil(err)
801802

802-
suiteManager.RegisterCleanUp("remove-lifecycle-"+lifecycle.Version(), func() error {
803-
img := imageManager.GetImageID(fmt.Sprintf("%s:%s", internalConfig.DefaultLifecycleImageRepo, lifecycle.Version()))
803+
suiteManager.RegisterCleanUp("remove-lifecycle-"+lifecycle.Image(), func() error {
804+
img := imageManager.GetImageID(lifecycle.Image())
804805
imageManager.CleanupImages(img)
805806
return nil
806807
})
807-
808-
assert.Nil(err)
809808
})
810809

811810
it.After(func() {

acceptance/config/asset_manager.go

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
acceptanceOS "github.com/buildpacks/pack/acceptance/os"
1515
"github.com/buildpacks/pack/internal/blob"
1616
"github.com/buildpacks/pack/internal/builder"
17+
"github.com/buildpacks/pack/internal/config"
1718
"github.com/buildpacks/pack/internal/style"
1819
h "github.com/buildpacks/pack/testhelpers"
1920
)
@@ -36,8 +37,10 @@ type AssetManager struct {
3637
githubAssetFetcher *GithubAssetFetcher
3738
lifecyclePath string
3839
lifecycleDescriptor builder.LifecycleDescriptor
40+
lifecycleImage string
3941
previousLifecyclePath string
4042
previousLifecycleDescriptor builder.LifecycleDescriptor
43+
previousLifecycleImage string
4144
defaultLifecycleDescriptor builder.LifecycleDescriptor
4245
testObject *testing.T
4346
}
@@ -50,8 +53,10 @@ func ConvergedAssetManager(t *testing.T, assert h.AssertionManager, inputConfig
5053
convergedPreviousPackPath string
5154
convergedPreviousPackFixturesPaths []string
5255
convergedCurrentLifecyclePath string
56+
convergedCurrentLifecycleImage string
5357
convergedCurrentLifecycleDescriptor builder.LifecycleDescriptor
5458
convergedPreviousLifecyclePath string
59+
convergedPreviousLifecycleImage string
5560
convergedPreviousLifecycleDescriptor builder.LifecycleDescriptor
5661
convergedDefaultLifecycleDescriptor builder.LifecycleDescriptor
5762
)
@@ -78,11 +83,11 @@ func ConvergedAssetManager(t *testing.T, assert h.AssertionManager, inputConfig
7883
}
7984

8085
if inputConfig.combinations.requiresCurrentLifecycle() {
81-
convergedCurrentLifecyclePath, convergedCurrentLifecycleDescriptor = assetBuilder.ensureCurrentLifecycle()
86+
convergedCurrentLifecyclePath, convergedCurrentLifecycleImage, convergedCurrentLifecycleDescriptor = assetBuilder.ensureCurrentLifecycle()
8287
}
8388

8489
if inputConfig.combinations.requiresPreviousLifecycle() {
85-
convergedPreviousLifecyclePath, convergedPreviousLifecycleDescriptor = assetBuilder.ensurePreviousLifecycle()
90+
convergedPreviousLifecyclePath, convergedPreviousLifecycleImage, convergedPreviousLifecycleDescriptor = assetBuilder.ensurePreviousLifecycle()
8691
}
8792

8893
if inputConfig.combinations.requiresDefaultLifecycle() {
@@ -95,8 +100,10 @@ func ConvergedAssetManager(t *testing.T, assert h.AssertionManager, inputConfig
95100
previousPackPath: convergedPreviousPackPath,
96101
previousPackFixturesPaths: convergedPreviousPackFixturesPaths,
97102
lifecyclePath: convergedCurrentLifecyclePath,
103+
lifecycleImage: convergedCurrentLifecycleImage,
98104
lifecycleDescriptor: convergedCurrentLifecycleDescriptor,
99105
previousLifecyclePath: convergedPreviousLifecyclePath,
106+
previousLifecycleImage: convergedPreviousLifecycleImage,
100107
previousLifecycleDescriptor: convergedPreviousLifecycleDescriptor,
101108
defaultLifecycleDescriptor: convergedDefaultLifecycleDescriptor,
102109
testObject: t,
@@ -152,6 +159,22 @@ func (a AssetManager) LifecycleDescriptor(kind ComboValue) builder.LifecycleDesc
152159
return builder.LifecycleDescriptor{} // Unreachable
153160
}
154161

162+
func (a AssetManager) LifecycleImage(kind ComboValue) string {
163+
a.testObject.Helper()
164+
165+
switch kind {
166+
case Current:
167+
return a.lifecycleImage
168+
case Previous:
169+
return a.previousLifecycleImage
170+
case DefaultKind:
171+
return fmt.Sprintf("%s:%s", config.DefaultLifecycleImageRepo, a.defaultLifecycleDescriptor.Info.Version)
172+
}
173+
174+
a.testObject.Fatalf("lifecycle kind must be previous, current or default was %s", kind)
175+
return "" // Unreachable
176+
}
177+
155178
type assetManagerBuilder struct {
156179
testObject *testing.T
157180
assert h.AssertionManager
@@ -235,7 +258,7 @@ func (b assetManagerBuilder) ensurePreviousPackFixtures() string {
235258
return fixturesDir
236259
}
237260

238-
func (b assetManagerBuilder) ensureCurrentLifecycle() (string, builder.LifecycleDescriptor) {
261+
func (b assetManagerBuilder) ensureCurrentLifecycle() (string, string, builder.LifecycleDescriptor) {
239262
b.testObject.Helper()
240263

241264
lifecyclePath := b.inputConfig.lifecyclePath
@@ -255,10 +278,18 @@ func (b assetManagerBuilder) ensureCurrentLifecycle() (string, builder.Lifecycle
255278
lifecycle, err := builder.NewLifecycle(blob.NewBlob(lifecyclePath))
256279
b.assert.Nil(err)
257280

258-
return lifecyclePath, lifecycle.Descriptor()
281+
lifecycleImage := b.inputConfig.lifecycleImage
282+
283+
if lifecycleImage == "" {
284+
lifecycleImage = fmt.Sprintf("%s:%s", config.DefaultLifecycleImageRepo, lifecycle.Descriptor().Info.Version)
285+
286+
b.testObject.Logf("using %s for current lifecycle image", lifecycleImage)
287+
}
288+
289+
return lifecyclePath, lifecycleImage, lifecycle.Descriptor()
259290
}
260291

261-
func (b assetManagerBuilder) ensurePreviousLifecycle() (string, builder.LifecycleDescriptor) {
292+
func (b assetManagerBuilder) ensurePreviousLifecycle() (string, string, builder.LifecycleDescriptor) {
262293
b.testObject.Helper()
263294

264295
previousLifecyclePath := b.inputConfig.previousLifecyclePath
@@ -278,7 +309,15 @@ func (b assetManagerBuilder) ensurePreviousLifecycle() (string, builder.Lifecycl
278309
lifecycle, err := builder.NewLifecycle(blob.NewBlob(previousLifecyclePath))
279310
b.assert.Nil(err)
280311

281-
return previousLifecyclePath, lifecycle.Descriptor()
312+
previousLifecycleImage := b.inputConfig.previousLifecycleImage
313+
314+
if previousLifecycleImage == "" {
315+
previousLifecycleImage = fmt.Sprintf("%s:%s", config.DefaultLifecycleImageRepo, lifecycle.Descriptor().Info.Version)
316+
317+
b.testObject.Logf("using %s for previous lifecycle image", previousLifecycleImage)
318+
}
319+
320+
return previousLifecyclePath, previousLifecycleImage, lifecycle.Descriptor()
282321
}
283322

284323
func (b assetManagerBuilder) downloadLifecycle(version string) string {

acceptance/config/input_configuration_manager.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ import (
1313
)
1414

1515
const (
16-
envPackPath = "PACK_PATH"
17-
envPreviousPackPath = "PREVIOUS_PACK_PATH"
18-
envPreviousPackFixturesPath = "PREVIOUS_PACK_FIXTURES_PATH"
19-
envLifecyclePath = "LIFECYCLE_PATH"
20-
envPreviousLifecyclePath = "PREVIOUS_LIFECYCLE_PATH"
21-
envGitHubToken = "GITHUB_TOKEN"
2216
envAcceptanceSuiteConfig = "ACCEPTANCE_SUITE_CONFIG"
2317
envCompilePackWithVersion = "COMPILE_PACK_WITH_VERSION"
18+
envGitHubToken = "GITHUB_TOKEN"
19+
envLifecycleImage = "LIFECYCLE_IMAGE"
20+
envLifecyclePath = "LIFECYCLE_PATH"
21+
envPackPath = "PACK_PATH"
22+
envPreviousLifecycleImage = "PREVIOUS_LIFECYCLE_IMAGE"
23+
envPreviousLifecyclePath = "PREVIOUS_LIFECYCLE_PATH"
24+
envPreviousPackFixturesPath = "PREVIOUS_PACK_FIXTURES_PATH"
25+
envPreviousPackPath = "PREVIOUS_PACK_PATH"
2426
)
2527

2628
type InputConfigurationManager struct {
@@ -29,6 +31,8 @@ type InputConfigurationManager struct {
2931
previousPackFixturesPath string
3032
lifecyclePath string
3133
previousLifecyclePath string
34+
lifecycleImage string
35+
previousLifecycleImage string
3236
compilePackWithVersion string
3337
githubToken string
3438
combinations ComboSet
@@ -40,8 +44,6 @@ func NewInputConfigurationManager() (InputConfigurationManager, error) {
4044
previousPackFixturesPath := os.Getenv(envPreviousPackFixturesPath)
4145
lifecyclePath := os.Getenv(envLifecyclePath)
4246
previousLifecyclePath := os.Getenv(envPreviousLifecyclePath)
43-
compilePackWithVersion := os.Getenv(envCompilePackWithVersion)
44-
githubToken := os.Getenv(envGitHubToken)
4547

4648
err := resolveAbsolutePaths(&packPath, &previousPackPath, &previousPackFixturesPath, &lifecyclePath, &previousLifecyclePath)
4749
if err != nil {
@@ -69,8 +71,10 @@ func NewInputConfigurationManager() (InputConfigurationManager, error) {
6971
previousPackFixturesPath: previousPackFixturesPath,
7072
lifecyclePath: lifecyclePath,
7173
previousLifecyclePath: previousLifecyclePath,
72-
compilePackWithVersion: compilePackWithVersion,
73-
githubToken: githubToken,
74+
lifecycleImage: os.Getenv(envLifecycleImage),
75+
previousLifecycleImage: os.Getenv(envPreviousLifecycleImage),
76+
compilePackWithVersion: os.Getenv(envCompilePackWithVersion),
77+
githubToken: os.Getenv(envGitHubToken),
7478
combinations: combos,
7579
}, nil
7680
}

acceptance/config/lifecycle_asset.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ import (
1515
type LifecycleAsset struct {
1616
path string
1717
descriptor builder.LifecycleDescriptor
18+
image string
1819
}
1920

2021
func (a AssetManager) NewLifecycleAsset(kind ComboValue) LifecycleAsset {
2122
return LifecycleAsset{
2223
path: a.LifecyclePath(kind),
2324
descriptor: a.LifecycleDescriptor(kind),
25+
image: a.LifecycleImage(kind),
2426
}
2527
}
2628

@@ -48,6 +50,10 @@ func (l *LifecycleAsset) EscapedPath() string {
4850
return strings.ReplaceAll(l.path, `\`, `\\`)
4951
}
5052

53+
func (l *LifecycleAsset) Image() string {
54+
return l.image
55+
}
56+
5157
func earliestVersion(versions []*api.Version) *api.Version {
5258
var earliest *api.Version
5359
for _, version := range versions {

build.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import (
44
"context"
55
"crypto/rand"
66
"fmt"
7-
"net/url"
87
"os"
98
"path/filepath"
10-
"runtime"
119
"sort"
1210
"strings"
1311

@@ -690,11 +688,6 @@ func (c *Client) processBuildpacks(ctx context.Context, builderImage imgutil.Ima
690688

691689
c.logger.Debugf("Downloading buildpack from URI: %s", style.Symbol(bp))
692690

693-
err := ensureBPSupport(bp)
694-
if err != nil {
695-
return fetchedBPs, order, errors.Wrapf(err, "checking support")
696-
}
697-
698691
blob, err := c.downloader.Download(ctx, bp)
699692
if err != nil {
700693
return fetchedBPs, order, errors.Wrapf(err, "downloading buildpack from %s", style.Symbol(bp))
@@ -787,37 +780,6 @@ func decomposeBuildpack(blob blob.Blob, imageOS string) (mainBP dist.Buildpack,
787780
return mainBP, depBPs, nil
788781
}
789782

790-
func ensureBPSupport(bpPath string) (err error) {
791-
p := bpPath
792-
if paths.IsURI(bpPath) {
793-
var u *url.URL
794-
u, err = url.Parse(bpPath)
795-
if err != nil {
796-
return err
797-
}
798-
799-
if u.Scheme == "file" {
800-
p, err = paths.URIToFilePath(bpPath)
801-
if err != nil {
802-
return err
803-
}
804-
}
805-
}
806-
807-
if runtime.GOOS == "windows" && !paths.IsURI(p) {
808-
isDir, err := paths.IsDir(p)
809-
if err != nil {
810-
return err
811-
}
812-
813-
if isDir {
814-
return fmt.Errorf("buildpack %s: directory-based buildpacks are not currently supported on Windows", style.Symbol(bpPath))
815-
}
816-
}
817-
818-
return nil
819-
}
820-
821783
func (c *Client) createEphemeralBuilder(rawBuilderImage imgutil.Image, env map[string]string, order dist.Order, buildpacks []dist.Buildpack) (*builder.Builder, error) {
822784
origBuilderName := rawBuilderImage.Name()
823785
bldr, err := builder.New(rawBuilderImage, fmt.Sprintf("pack.local/builder/%x:latest", randString(10)))

0 commit comments

Comments
 (0)