diff options
author | baude <bbaude@redhat.com> | 2018-06-05 13:18:52 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-06-05 19:31:13 +0000 |
commit | 06a29f0bdeeaca1591e80aac8e08b5363fdb9977 (patch) | |
tree | c8c1a7cb4d9573e17cb2ce29fbb202af4ced7fb7 /pkg | |
parent | 7965bf54048044d63f967d2b4ce8efe1e1072f05 (diff) | |
download | podman-06a29f0bdeeaca1591e80aac8e08b5363fdb9977.tar.gz podman-06a29f0bdeeaca1591e80aac8e08b5363fdb9977.tar.bz2 podman-06a29f0bdeeaca1591e80aac8e08b5363fdb9977.zip |
varlink build fixes
the varlink build was not working as designed and required some touch-ups:
* return a struct that includes logs and the new image ID
* pass namespaceoption so that networking in buildah works
Signed-off-by: baude <bbaude@redhat.com>
Closes: #903
Approved by: rhatdan
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/varlinkapi/images.go | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go index d80c7043a..420962973 100644 --- a/pkg/varlinkapi/images.go +++ b/pkg/varlinkapi/images.go @@ -13,6 +13,7 @@ import ( "github.com/containers/image/types" "github.com/docker/go-units" "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" "github.com/projectatomic/buildah" "github.com/projectatomic/buildah/imagebuildah" @@ -99,6 +100,7 @@ func (i *LibpodAPI) BuildImage(call ioprojectatomicpodman.VarlinkCall, config io var ( memoryLimit int64 memorySwap int64 + namespace []buildah.NamespaceOption ) runtime, err := libpodruntime.GetRuntime(i.Cli) @@ -181,6 +183,13 @@ func (i *LibpodAPI) BuildImage(call ioprojectatomicpodman.VarlinkCall, config io Volumes: config.Volume, } + hostNetwork := buildah.NamespaceOption{ + Name: specs.NetworkNamespace, + Host: true, + } + + namespace = append(namespace, hostNetwork) + options := imagebuildah.BuildOptions{ ContextDirectory: contextDir, PullPolicy: pullPolicy, @@ -192,13 +201,14 @@ func (i *LibpodAPI) BuildImage(call ioprojectatomicpodman.VarlinkCall, config io AdditionalTags: config.Tags, //Runtime: runtime. //RuntimeArgs: , - OutputFormat: format, - SystemContext: &systemContext, - CommonBuildOpts: commonOpts, - Squash: config.Squash, - Labels: config.Label, - Annotations: config.Annotations, - ReportWriter: output, + OutputFormat: format, + SystemContext: &systemContext, + CommonBuildOpts: commonOpts, + Squash: config.Squash, + Labels: config.Label, + Annotations: config.Annotations, + ReportWriter: output, + NamespaceOptions: namespace, } if call.WantsMore() { @@ -225,7 +235,10 @@ func (i *LibpodAPI) BuildImage(call ioprojectatomicpodman.VarlinkCall, config io time.Sleep(1 * time.Second) break } - call.ReplyBuildImage(log) + br := ioprojectatomicpodman.BuildResponse{ + Logs: log, + } + call.ReplyBuildImage(br) log = []string{} } } else { @@ -236,7 +249,15 @@ func (i *LibpodAPI) BuildImage(call ioprojectatomicpodman.VarlinkCall, config io } } call.Continues = false - return call.ReplyBuildImage(log) + newImage, err := runtime.ImageRuntime().NewFromLocal(config.Tags[0]) + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + br := ioprojectatomicpodman.BuildResponse{ + Logs: log, + Id: newImage.ID(), + } + return call.ReplyBuildImage(br) } func build(runtime *libpod.Runtime, options imagebuildah.BuildOptions, dockerfiles []string) chan error { |