Skip to content

Commit 04b9e4b

Browse files
author
Priya Wadhwa
committed
Use mutable source directly
1 parent 98826ef commit 04b9e4b

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ REPOPATH ?= $(ORG)/$(PROJECT)
2929

3030
GO_FILES := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
3131
GO_LDFLAGS := '-extldflags "-static"'
32-
GO_BUILD_TAGS := "containers_image_ostree_stub containers_image_openpgp exclude_graphdriver_devicemapper exclude_graphdriver_btrfs"
32+
GO_BUILD_TAGS := "containers_image_ostree_stub containers_image_openpgp exclude_graphdriver_devicemapper exclude_graphdriver_btrfs exclude_graphdriver_overlay"
3333

3434
EXECUTOR_PACKAGE = $(REPOPATH)/executor
3535
KBUILD_PACKAGE = $(REPOPATH)/kbuild
3636

3737
out/executor: $(GO_FILES)
38-
GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=1 go build -ldflags $(GO_LDFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(EXECUTOR_PACKAGE)
38+
GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(EXECUTOR_PACKAGE)
3939

4040

4141
out/kbuild: $(GO_FILES)
42-
GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=1 go build -ldflags $(GO_LDFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(KBUILD_PACKAGE)
42+
GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(KBUILD_PACKAGE)
4343

4444
.PHONY: test
4545
test: out/executor out/kbuild

executor/cmd/root.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,13 @@ func execute() error {
8383
}
8484

8585
// Initialize source image
86-
if err := image.InitializeSourceImage(baseImage); err != nil {
86+
sourceImage, err := image.NewSourceImage(baseImage)
87+
if err != nil {
8788
return err
8889
}
8990

9091
// Execute commands here
9192

9293
// Push the image
93-
return image.PushImage(destination)
94+
return image.PushImage(sourceImage, destination)
9495
}

pkg/image/image.go

+5-16
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,22 @@ import (
2626
)
2727

2828
// sourceImage is the image that will be modified by the executor
29-
var sourceImage img.MutableSource
3029

3130
// InitializeSourceImage initializes the source image with the base image
32-
func InitializeSourceImage(srcImg string) error {
31+
func NewSourceImage(srcImg string) (*img.MutableSource, error) {
3332
logrus.Infof("Initializing source image %s", srcImg)
3433
ref, err := docker.ParseReference("//" + srcImg)
3534
if err != nil {
36-
return err
37-
}
38-
ms, err := img.NewMutableSource(ref)
39-
if err != nil {
40-
return err
35+
return nil, err
4136
}
42-
sourceImage = *ms
43-
return nil
44-
}
45-
46-
// AppendLayer appends a layer onto the base image
47-
func AppendLayer(contents []byte, author string) error {
48-
return sourceImage.AppendLayer(contents, author)
37+
return img.NewMutableSource(ref)
4938
}
5039

5140
// PushImage pushes the final image
52-
func PushImage(destImg string) error {
41+
func PushImage(ms *img.MutableSource, destImg string) error {
5342
srcRef := &img.ProxyReference{
5443
ImageReference: nil,
55-
Src: &sourceImage,
44+
Src: ms,
5645
}
5746
destRef, err := alltransports.ParseImageName("docker://" + destImg)
5847
if err != nil {

0 commit comments

Comments
 (0)