summaryrefslogtreecommitdiff
path: root/pkg/domain
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/domain')
-rw-r--r--pkg/domain/entities/images.go30
-rw-r--r--pkg/domain/infra/abi/images.go3
-rw-r--r--pkg/domain/infra/abi/images_list.go24
-rw-r--r--pkg/domain/infra/abi/play.go18
-rw-r--r--pkg/domain/infra/abi/terminal/terminal.go2
-rw-r--r--pkg/domain/infra/runtime_libpod.go17
-rw-r--r--pkg/domain/infra/tunnel/images.go93
7 files changed, 51 insertions, 136 deletions
diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go
index 2a8133680..d0b738934 100644
--- a/pkg/domain/entities/images.go
+++ b/pkg/domain/entities/images.go
@@ -45,7 +45,7 @@ type Image struct {
HealthCheck *manifest.Schema2HealthConfig `json:",omitempty"`
}
-func (i *Image) Id() string { //nolint
+func (i *Image) Id() string { // nolint
return i.ID
}
@@ -70,7 +70,7 @@ type ImageSummary struct {
History []string `json:",omitempty"`
}
-func (i *ImageSummary) Id() string { //nolint
+func (i *ImageSummary) Id() string { // nolint
return i.ID
}
@@ -150,7 +150,12 @@ type ImagePullOptions struct {
// ImagePullReport is the response from pulling one or more images.
type ImagePullReport struct {
- Images []string
+ // Stream used to provide output from c/image
+ Stream string `json:"stream,omitempty"`
+ // Error contains text of errors from c/image
+ Error string `json:"error,omitempty"`
+ // Images contains the ID's of the images pulled
+ Images []string `json:"images,omitempty"`
}
// ImagePushOptions are the arguments for pushing images.
@@ -259,16 +264,17 @@ type ImageLoadReport struct {
}
type ImageImportOptions struct {
- Changes []string
- Message string
- Quiet bool
- Reference string
- Source string
- SourceIsURL bool
+ Changes []string
+ Message string
+ Quiet bool
+ Reference string
+ SignaturePolicy string
+ Source string
+ SourceIsURL bool
}
type ImageImportReport struct {
- Id string //nolint
+ Id string // nolint
}
// ImageSaveOptions provide options for saving images.
@@ -348,7 +354,7 @@ type ImageUnmountOptions struct {
// ImageMountReport describes the response from image mount
type ImageMountReport struct {
Err error
- Id string //nolint
+ Id string // nolint
Name string
Repositories []string
Path string
@@ -357,5 +363,5 @@ type ImageMountReport struct {
// ImageUnmountReport describes the response from umounting an image
type ImageUnmountReport struct {
Err error
- Id string //nolint
+ Id string // nolint
}
diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go
index 23aef9573..cc62c3f27 100644
--- a/pkg/domain/infra/abi/images.go
+++ b/pkg/domain/infra/abi/images.go
@@ -467,7 +467,7 @@ func (ir *ImageEngine) Load(ctx context.Context, opts entities.ImageLoadOptions)
}
func (ir *ImageEngine) Import(ctx context.Context, opts entities.ImageImportOptions) (*entities.ImageImportReport, error) {
- id, err := ir.Libpod.Import(ctx, opts.Source, opts.Reference, opts.Changes, opts.Message, opts.Quiet)
+ id, err := ir.Libpod.Import(ctx, opts.Source, opts.Reference, opts.SignaturePolicy, opts.Changes, opts.Message, opts.Quiet)
if err != nil {
return nil, err
}
@@ -535,6 +535,7 @@ func (ir *ImageEngine) Config(_ context.Context) (*config.Config, error) {
}
func (ir *ImageEngine) Build(ctx context.Context, containerFiles []string, opts entities.BuildOptions) (*entities.BuildReport, error) {
+
id, _, err := ir.Libpod.Build(ctx, opts.BuildOptions, containerFiles...)
if err != nil {
return nil, err
diff --git a/pkg/domain/infra/abi/images_list.go b/pkg/domain/infra/abi/images_list.go
index 7ec84246d..3e47dc67a 100644
--- a/pkg/domain/infra/abi/images_list.go
+++ b/pkg/domain/infra/abi/images_list.go
@@ -23,33 +23,13 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions)
summaries := []*entities.ImageSummary{}
for _, img := range images {
- var repoTags []string
- if opts.All {
- pairs, err := libpodImage.ReposToMap(img.Names())
- if err != nil {
- return nil, err
- }
-
- for repo, tags := range pairs {
- for _, tag := range tags {
- repoTags = append(repoTags, repo+":"+tag)
- }
- }
- } else {
- repoTags, err = img.RepoTags()
- if err != nil {
- return nil, err
- }
- }
-
digests := make([]string, len(img.Digests()))
for j, d := range img.Digests() {
digests[j] = string(d)
}
e := entities.ImageSummary{
- ID: img.ID(),
-
+ ID: img.ID(),
ConfigDigest: string(img.ConfigDigest),
Created: img.Created().Unix(),
Dangling: img.Dangling(),
@@ -61,7 +41,7 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions)
ReadOnly: img.IsReadOnly(),
SharedSize: 0,
VirtualSize: img.VirtualSize,
- RepoTags: repoTags,
+ RepoTags: img.Names(), // may include tags and digests
}
e.Labels, _ = img.Labels(context.TODO())
diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go
index 6dfb52c63..aa6aeede2 100644
--- a/pkg/domain/infra/abi/play.go
+++ b/pkg/domain/infra/abi/play.go
@@ -132,6 +132,11 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
libpod.WithInfraContainer(),
libpod.WithPodName(podName),
}
+
+ if podYAML.ObjectMeta.Labels != nil {
+ podOptions = append(podOptions, libpod.WithPodLabels(podYAML.ObjectMeta.Labels))
+ }
+
// TODO we only configure Process namespace. We also need to account for Host{IPC,Network,PID}
// which is not currently possible with pod create
if podYAML.Spec.ShareProcessNamespace != nil && *podYAML.Spec.ShareProcessNamespace {
@@ -294,6 +299,18 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
return nil, err
}
+ var ctrRestartPolicy string
+ switch podYAML.Spec.RestartPolicy {
+ case v1.RestartPolicyAlways:
+ ctrRestartPolicy = libpod.RestartPolicyAlways
+ case v1.RestartPolicyOnFailure:
+ ctrRestartPolicy = libpod.RestartPolicyOnFailure
+ case v1.RestartPolicyNever:
+ ctrRestartPolicy = libpod.RestartPolicyNo
+ default: // Default to Always
+ ctrRestartPolicy = libpod.RestartPolicyAlways
+ }
+
containers := make([]*libpod.Container, 0, len(podYAML.Spec.Containers))
for _, container := range podYAML.Spec.Containers {
pullPolicy := util.PullImageMissing
@@ -321,6 +338,7 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
if err != nil {
return nil, err
}
+ conf.RestartPolicy = ctrRestartPolicy
ctr, err := createconfig.CreateContainerFromCreateConfig(ctx, ic.Libpod, conf, pod)
if err != nil {
return nil, err
diff --git a/pkg/domain/infra/abi/terminal/terminal.go b/pkg/domain/infra/abi/terminal/terminal.go
index 0b6e57f49..48f5749d5 100644
--- a/pkg/domain/infra/abi/terminal/terminal.go
+++ b/pkg/domain/infra/abi/terminal/terminal.go
@@ -6,7 +6,7 @@ import (
"os/signal"
lsignal "github.com/containers/podman/v2/pkg/signal"
- "github.com/docker/docker/pkg/term"
+ "github.com/moby/term"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"k8s.io/client-go/tools/remotecommand"
diff --git a/pkg/domain/infra/runtime_libpod.go b/pkg/domain/infra/runtime_libpod.go
index f9b8106ef..26c9c7e2e 100644
--- a/pkg/domain/infra/runtime_libpod.go
+++ b/pkg/domain/infra/runtime_libpod.go
@@ -227,23 +227,6 @@ func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpo
// TODO flag to set CNI plugins dir?
- // TODO I don't think these belong here?
- // Will follow up with a different PR to address
- //
- // Pod create options
-
- infraImageFlag := fs.Lookup("infra-image")
- if infraImageFlag != nil && infraImageFlag.Changed {
- infraImage, _ := fs.GetString("infra-image")
- options = append(options, libpod.WithDefaultInfraImage(infraImage))
- }
-
- infraCommandFlag := fs.Lookup("infra-command")
- if infraCommandFlag != nil && infraImageFlag.Changed {
- infraCommand, _ := fs.GetString("infra-command")
- options = append(options, libpod.WithDefaultInfraCommand(infraCommand))
- }
-
if !opts.withFDS {
options = append(options, libpod.WithEnableSDNotify())
}
diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go
index 185cc2f9a..332a7c2eb 100644
--- a/pkg/domain/infra/tunnel/images.go
+++ b/pkg/domain/infra/tunnel/images.go
@@ -1,13 +1,9 @@
package tunnel
import (
- "archive/tar"
- "bytes"
"context"
- "io"
"io/ioutil"
"os"
- "path/filepath"
"strings"
"time"
@@ -18,9 +14,7 @@ import (
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/domain/utils"
utils2 "github.com/containers/podman/v2/utils"
- "github.com/containers/storage/pkg/archive"
"github.com/pkg/errors"
- "github.com/sirupsen/logrus"
)
func (ir *ImageEngine) Exists(_ context.Context, nameOrID string) (*entities.BoolReport, error) {
@@ -311,28 +305,23 @@ func (ir *ImageEngine) Config(_ context.Context) (*config.Config, error) {
return config.Default()
}
-func (ir *ImageEngine) Build(ctx context.Context, containerFiles []string, opts entities.BuildOptions) (*entities.BuildReport, error) {
- var tarReader io.Reader
- tarfile, err := archive.Tar(opts.ContextDirectory, 0)
+func (ir *ImageEngine) Build(_ context.Context, containerFiles []string, opts entities.BuildOptions) (*entities.BuildReport, error) {
+ report, err := images.Build(ir.ClientCxt, containerFiles, opts)
if err != nil {
return nil, err
}
- tarReader = tarfile
- cwd, err := os.Getwd()
- if err != nil {
- return nil, err
- }
- if cwd != opts.ContextDirectory {
- fn := func(h *tar.Header, r io.Reader) (data []byte, update bool, skip bool, err error) {
- h.Name = filepath.Join(filepath.Base(opts.ContextDirectory), h.Name)
- return nil, false, false, nil
- }
- tarReader, err = transformArchive(tarfile, false, fn)
+ // For remote clients, if the option for writing to a file was
+ // selected, we need to write to the *client's* filesystem.
+ if len(opts.IIDFile) > 0 {
+ f, err := os.Create(opts.IIDFile)
if err != nil {
return nil, err
}
+ if _, err := f.WriteString(report.ID); err != nil {
+ return nil, err
+ }
}
- return images.Build(ir.ClientCxt, containerFiles, opts, tarReader)
+ return report, nil
}
func (ir *ImageEngine) Tree(ctx context.Context, nameOrID string, opts entities.ImageTreeOptions) (*entities.ImageTreeReport, error) {
@@ -346,65 +335,3 @@ func (ir *ImageEngine) Shutdown(_ context.Context) {
func (ir *ImageEngine) Sign(ctx context.Context, names []string, options entities.SignOptions) (*entities.SignReport, error) {
return nil, errors.New("not implemented yet")
}
-
-// Sourced from openshift image builder
-
-// TransformFileFunc is given a chance to transform an arbitrary input file.
-type TransformFileFunc func(h *tar.Header, r io.Reader) (data []byte, update bool, skip bool, err error)
-
-// filterArchive transforms the provided input archive to a new archive,
-// giving the fn a chance to transform arbitrary files.
-func filterArchive(r io.Reader, w io.Writer, fn TransformFileFunc) error {
- tr := tar.NewReader(r)
- tw := tar.NewWriter(w)
-
- var body io.Reader = tr
-
- for {
- h, err := tr.Next()
- if err == io.EOF {
- return tw.Close()
- }
- if err != nil {
- return err
- }
-
- name := h.Name
- data, ok, skip, err := fn(h, tr)
- logrus.Debugf("Transform %q -> %q: data=%t ok=%t skip=%t err=%v", name, h.Name, data != nil, ok, skip, err)
- if err != nil {
- return err
- }
- if skip {
- continue
- }
- if ok {
- h.Size = int64(len(data))
- body = bytes.NewBuffer(data)
- }
- if err := tw.WriteHeader(h); err != nil {
- return err
- }
- if _, err := io.Copy(tw, body); err != nil {
- return err
- }
- }
-}
-
-func transformArchive(r io.Reader, compressed bool, fn TransformFileFunc) (io.Reader, error) {
- var cwe error
- pr, pw := io.Pipe()
- go func() {
- if compressed {
- in, err := archive.DecompressStream(r)
- if err != nil {
- cwe = pw.CloseWithError(err)
- return
- }
- r = in
- }
- err := filterArchive(r, pw, fn)
- cwe = pw.CloseWithError(err)
- }()
- return pr, cwe
-}