Use mutable source directly
This commit is contained in:
parent
98826ef951
commit
04b9e4bcdf
6
Makefile
6
Makefile
|
|
@ -29,17 +29,17 @@ REPOPATH ?= $(ORG)/$(PROJECT)
|
|||
|
||||
GO_FILES := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
GO_LDFLAGS := '-extldflags "-static"'
|
||||
GO_BUILD_TAGS := "containers_image_ostree_stub containers_image_openpgp exclude_graphdriver_devicemapper exclude_graphdriver_btrfs"
|
||||
GO_BUILD_TAGS := "containers_image_ostree_stub containers_image_openpgp exclude_graphdriver_devicemapper exclude_graphdriver_btrfs exclude_graphdriver_overlay"
|
||||
|
||||
EXECUTOR_PACKAGE = $(REPOPATH)/executor
|
||||
KBUILD_PACKAGE = $(REPOPATH)/kbuild
|
||||
|
||||
out/executor: $(GO_FILES)
|
||||
GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=1 go build -ldflags $(GO_LDFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(EXECUTOR_PACKAGE)
|
||||
GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(EXECUTOR_PACKAGE)
|
||||
|
||||
|
||||
out/kbuild: $(GO_FILES)
|
||||
GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=1 go build -ldflags $(GO_LDFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(KBUILD_PACKAGE)
|
||||
GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(KBUILD_PACKAGE)
|
||||
|
||||
.PHONY: test
|
||||
test: out/executor out/kbuild
|
||||
|
|
|
|||
|
|
@ -83,12 +83,13 @@ func execute() error {
|
|||
}
|
||||
|
||||
// Initialize source image
|
||||
if err := image.InitializeSourceImage(baseImage); err != nil {
|
||||
sourceImage, err := image.NewSourceImage(baseImage)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Execute commands here
|
||||
|
||||
// Push the image
|
||||
return image.PushImage(destination)
|
||||
return image.PushImage(sourceImage, destination)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,33 +26,22 @@ import (
|
|||
)
|
||||
|
||||
// sourceImage is the image that will be modified by the executor
|
||||
var sourceImage img.MutableSource
|
||||
|
||||
// InitializeSourceImage initializes the source image with the base image
|
||||
func InitializeSourceImage(srcImg string) error {
|
||||
func NewSourceImage(srcImg string) (*img.MutableSource, error) {
|
||||
logrus.Infof("Initializing source image %s", srcImg)
|
||||
ref, err := docker.ParseReference("//" + srcImg)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
ms, err := img.NewMutableSource(ref)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sourceImage = *ms
|
||||
return nil
|
||||
}
|
||||
|
||||
// AppendLayer appends a layer onto the base image
|
||||
func AppendLayer(contents []byte, author string) error {
|
||||
return sourceImage.AppendLayer(contents, author)
|
||||
return img.NewMutableSource(ref)
|
||||
}
|
||||
|
||||
// PushImage pushes the final image
|
||||
func PushImage(destImg string) error {
|
||||
func PushImage(ms *img.MutableSource, destImg string) error {
|
||||
srcRef := &img.ProxyReference{
|
||||
ImageReference: nil,
|
||||
Src: &sourceImage,
|
||||
Src: ms,
|
||||
}
|
||||
destRef, err := alltransports.ParseImageName("docker://" + destImg)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue