Skip to content

Commit

Permalink
merge updates
Browse files Browse the repository at this point in the history
Signed-off-by: dwillist <[email protected]>
  • Loading branch information
dwillist committed Jun 2, 2021
2 parents 9208e55 + 7a08937 commit 60fb6a0
Show file tree
Hide file tree
Showing 41 changed files with 1,162 additions and 1,020 deletions.
2 changes: 1 addition & 1 deletion acceptance/testdata/pack_fixtures/report_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Pack:
Version: {{ .Version }}
OS/Arch: {{ .OS }}/{{ .Arch }}

Default Lifecycle Version: 0.10.2
Default Lifecycle Version: 0.11.3

Supported Platform APIs: 0.3, 0.4

Expand Down
4 changes: 4 additions & 0 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ type BuildOptions struct {

// The location at which to mount the AppDir in the build image.
Workspace string

// User's group id used to build the image
GroupID int
}

// ProxyConfig specifies proxy setting to be set as environment variables in a container.
Expand Down Expand Up @@ -317,6 +320,7 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error {
FileFilter: fileFilter,
CacheImage: opts.CacheImage,
Workspace: opts.Workspace,
GID: opts.GroupID,
}

lifecycleVersion := ephemeralBuilder.LifecycleDescriptor().Info.Version
Expand Down
14 changes: 13 additions & 1 deletion build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,7 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
h.AssertEq(t, args.Daemon, true)
h.AssertEq(t, args.PullPolicy, config.PullNever)

args = fakeImageFetcher.FetchCalls["buildpacksio/lifecycle:0.10.2"]
args = fakeImageFetcher.FetchCalls["buildpacksio/lifecycle:0.11.3"]
h.AssertEq(t, args.Daemon, true)
h.AssertEq(t, args.PullPolicy, config.PullNever)
})
Expand Down Expand Up @@ -2203,6 +2203,18 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
})
})
})

when("gid option", func() {
it("gid is passthroughs to lifecycle", func() {
h.AssertNil(t, subject.Build(context.TODO(), BuildOptions{
Workspace: "app",
Builder: defaultBuilderName,
Image: "example.com/some/repo:tag",
GroupID: 2,
}))
h.AssertEq(t, fakeLifecycle.Opts.GID, 2)
})
})
})
}

Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type AssetFetcher interface {
type ImageFactory interface {
// NewImage initializes an image object with required settings so that it
// can be written either locally or to a registry.
NewImage(repoName string, local bool) (imgutil.Image, error)
NewImage(repoName string, local bool, imageOS string) (imgutil.Image, error)
}

// Client is an orchestration object, it contains all parameters needed to
Expand Down
5 changes: 1 addition & 4 deletions create_asset_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,10 @@ func (c *Client) CreateAssetPackage(ctx context.Context, opts CreateAssetPackage
}

func newImageWithOS(imgName, os string, local bool, imgFactory ImageFactory) (imgutil.Image, error) {
img, err := imgFactory.NewImage(imgName, local)
img, err := imgFactory.NewImage(imgName, local, os)
if err != nil {
return nil, err
}
if err := img.SetOS(os); err != nil {
return nil, err
}
return img, nil
}

Expand Down
19 changes: 8 additions & 11 deletions create_asset_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func testCreateAssetCacheCommand(t *testing.T, when spec.G, it spec.S) {
assert.Nil(err)

fakeImage := fakes.NewImage(imgRef.Name(), "", nil)
mockImageFactory.EXPECT().NewImage(imgRef.Name(), true).Return(fakeImage, nil)
mockImageFactory.EXPECT().NewImage(imgRef.Name(), true, "linux").Return(fakeImage, nil)
mockDownloader.EXPECT().Download(gomock.Any(), firstAsset.URI, gomock.Any(), gomock.Any()).Return(firstAssetBlob, nil)
mockDownloader.EXPECT().Download(gomock.Any(), secondAsset.URI, gomock.Any(), gomock.Any()).Return(secondAssetBlob, nil)

Expand Down Expand Up @@ -227,7 +227,7 @@ func testCreateAssetCacheCommand(t *testing.T, when spec.G, it spec.S) {
assert.Nil(err)

fakeImage := fakes.NewImage(imgRef.Name(), "", nil)
mockImageFactory.EXPECT().NewImage(imgRef.Name(), true).Return(fakeImage, nil)
mockImageFactory.EXPECT().NewImage(imgRef.Name(), true, "windows").Return(fakeImage, nil)
mockDownloader.EXPECT().Download(gomock.Any(), firstAsset.URI, gomock.Any(), gomock.Any()).Return(firstAssetBlob, nil)

assert.Succeeds(client.CreateAssetPackage(ctx, pack.CreateAssetPackageOptions{
Expand Down Expand Up @@ -255,11 +255,8 @@ func testCreateAssetCacheCommand(t *testing.T, when spec.G, it spec.S) {

assert.Equal(fakeImage.IsSaved(), true)

os, err := fakeImage.OS()
assert.Nil(err)
assert.Equal(os, "windows")

assert.Equal(fakeImage.NumberOfAddedLayers(), 2)
// windows layer will be added by image factory
assert.Equal(fakeImage.NumberOfAddedLayers(), 1)

firstLayer, err := fakeImage.GetLayer(md[firstAsset.Sha256].LayerDiffID)
assert.Nil(err)
Expand All @@ -275,7 +272,7 @@ func testCreateAssetCacheCommand(t *testing.T, when spec.G, it spec.S) {
assert.Nil(err)

fakeImage := fakes.NewImage(imgRef.Name(), "", nil)
mockImageFactory.EXPECT().NewImage(imgRef.Name(), false).Return(fakeImage, nil)
mockImageFactory.EXPECT().NewImage(imgRef.Name(), false, "windows").Return(fakeImage, nil)
mockDownloader.EXPECT().Download(gomock.Any(), firstAsset.URI, gomock.Any(), gomock.Any()).Return(firstAssetBlob, nil)

assert.Succeeds(client.CreateAssetPackage(ctx, pack.CreateAssetPackageOptions{
Expand All @@ -296,7 +293,7 @@ func testCreateAssetCacheCommand(t *testing.T, when spec.G, it spec.S) {
assert.Nil(err)

fakeImage := fakes.NewImage(imgRef.Name(), "", nil)
mockImageFactory.EXPECT().NewImage(imgRef.Name(), true).Return(fakeImage, nil)
mockImageFactory.EXPECT().NewImage(imgRef.Name(), true, "linux").Return(fakeImage, nil)
mockDownloader.EXPECT().Download(gomock.Any(), firstAssetReplace.URI, gomock.Any(), gomock.Any()).Return(firstAssetReplaceBlob, nil)

assert.Succeeds(client.CreateAssetPackage(ctx, pack.CreateAssetPackageOptions{
Expand Down Expand Up @@ -352,7 +349,7 @@ func testCreateAssetCacheCommand(t *testing.T, when spec.G, it spec.S) {
it("errors with a helpful message", func() {
ctx := context.TODO()
imgName := "fail-image-ref"
mockImageFactory.EXPECT().NewImage(imgName, true).Return(nil, errors.New("image create error"))
mockImageFactory.EXPECT().NewImage(imgName, true, "linux").Return(nil, errors.New("image create error"))
err := client.CreateAssetPackage(ctx, pack.CreateAssetPackageOptions{
ImageName: imgName,
Assets: []dist.AssetInfo{},
Expand Down Expand Up @@ -382,7 +379,7 @@ func testCreateAssetCacheCommand(t *testing.T, when spec.G, it spec.S) {
imgName := "fail-image-ref"

fakeImage := fakes.NewImage(imgName, "", nil)
mockImageFactory.EXPECT().NewImage(imgName, true).Return(fakeImage, nil)
mockImageFactory.EXPECT().NewImage(imgName, true, "linux").Return(fakeImage, nil)
err := client.CreateAssetPackage(ctx, pack.CreateAssetPackageOptions{
ImageName: imgName,
Assets: []dist.AssetInfo{firstAsset},
Expand Down
4 changes: 2 additions & 2 deletions create_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {

var createPackage = func(imageName string) *fakes.Image {
packageImage := fakes.NewImage(imageName, "", nil)
mockImageFactory.EXPECT().NewImage(packageImage.Name(), false).Return(packageImage, nil)
mockImageFactory.EXPECT().NewImage(packageImage.Name(), false, "linux").Return(packageImage, nil)

h.AssertNil(t, subject.PackageBuildpack(context.TODO(), pack.PackageBuildpackOptions{
Name: packageImage.Name(),
Expand Down Expand Up @@ -901,7 +901,7 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) {
when("package image lives in docker registry", func() {
it.Before(func() {
packageImage = fakes.NewImage("docker.io/some/package-"+h.RandString(12), "", nil)
mockImageFactory.EXPECT().NewImage(packageImage.Name(), false).Return(packageImage, nil)
mockImageFactory.EXPECT().NewImage(packageImage.Name(), false, "linux").Return(packageImage, nil)

bpd := dist.BuildpackDescriptor{
API: api.MustParse("0.3"),
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ require (
github.com/Masterminds/semver v1.5.0
github.com/Microsoft/hcsshim v0.8.10 // indirect
github.com/apex/log v1.9.0
github.com/buildpacks/imgutil v0.0.0-20210209163614-30601e371ce3
github.com/buildpacks/lifecycle v0.10.2
github.com/buildpacks/imgutil v0.0.0-20210510154637-009f91f52918
github.com/buildpacks/lifecycle v0.11.3
github.com/containerd/containerd v1.4.1 // indirect
github.com/containerd/continuity v0.0.0-20200107194136-26c1120b8d41 // indirect
github.com/docker/docker v20.10.0-beta1.0.20201110211921-af34b94a78a1+incompatible
github.com/docker/docker v20.10.6+incompatible
github.com/docker/go-connections v0.4.0
github.com/ghodss/yaml v1.0.0
github.com/golang/mock v1.5.0
github.com/google/go-cmp v0.5.5
github.com/google/go-cmp v0.5.6
github.com/google/go-containerregistry v0.5.1
github.com/google/go-github/v30 v30.1.0
github.com/heroku/color v0.0.6
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mitchellh/ioprogress v0.0.0-20180201004757-6a23b12fa88e
github.com/moby/sys/mount v0.2.0 // indirect
github.com/moby/term v0.0.0-20201110203204-bea5bbe245bf // indirect
github.com/onsi/gomega v1.12.0
github.com/onsi/gomega v1.13.0
github.com/opencontainers/image-spec v1.0.1
github.com/opencontainers/runc v0.1.1 // indirect
github.com/opencontainers/selinux v1.6.0 // indirect
Expand Down
Loading

0 comments on commit 60fb6a0

Please sign in to comment.