Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to containers/image v5, support manifest lists #4310

Merged
merged 7 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,10 @@ oomKillDisable [?bool](#?bool)

oomScoreAdj [?int](#?int)

overrideArch [?string](#?string)

overrideOS [?string](#?string)

pid [?string](#?string)

pidsLimit [?int](#?int)
Expand Down Expand Up @@ -1671,6 +1675,8 @@ id [string](https://godoc.org/builtin#string)

digest [string](https://godoc.org/builtin#string)

digests [[]string](#[]string)

parentId [string](https://godoc.org/builtin#string)

repoTags [[]string](#[]string)
Expand Down
7 changes: 6 additions & 1 deletion cmd/podman/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/containers/buildah"
"github.com/containers/buildah/imagebuildah"
buildahcli "github.com/containers/buildah/pkg/cli"
"github.com/containers/image/v5/types"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/adapter"
Expand Down Expand Up @@ -360,7 +361,11 @@ func buildCmd(c *cliconfig.BuildValues) error {
RuntimeArgs: runtimeFlags,
SignaturePolicyPath: c.SignaturePolicy,
Squash: c.Squash,
Target: c.Target,
SystemContext: &types.SystemContext{
OSChoice: c.OverrideOS,
ArchitectureChoice: c.OverrideArch,
},
Target: c.Target,
}
return runtime.Build(getContext(), c, options, containerfiles)
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/podman/cliconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ type PullValues struct {
Authfile string
CertDir string
Creds string
OverrideArch string
OverrideOS string
Quiet bool
SignaturePolicy string
TlsVerify bool
Expand Down
10 changes: 10 additions & 0 deletions cmd/podman/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,16 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
"oom-score-adj", 0,
"Tune the host's OOM preferences (-1000 to 1000)",
)
createFlags.String(
"override-arch", "",
"use `ARCH` instead of the architecture of the machine for choosing images",
)
markFlagHidden(createFlags, "override-arch")
createFlags.String(
"override-os", "",
"use `OS` instead of the running OS for choosing images",
)
markFlagHidden(createFlags, "override-os")
createFlags.String(
"pid", "",
"PID namespace to use",
Expand Down
30 changes: 19 additions & 11 deletions cmd/podman/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ type imagesTemplateParams struct {
Tag string
ID string
Digest digest.Digest
Digests []digest.Digest
Created string
CreatedTime time.Time
Size string
ReadOnly bool
}

type imagesJSONParams struct {
ID string `json:"id"`
Name []string `json:"names"`
Digest digest.Digest `json:"digest"`
Created time.Time `json:"created"`
Size *uint64 `json:"size"`
ReadOnly bool `json:"readonly"`
ID string `json:"id"`
Name []string `json:"names"`
Digest digest.Digest `json:"digest"`
Digests []digest.Digest `json:"digests"`
Created time.Time `json:"created"`
Size *uint64 `json:"size"`
ReadOnly bool `json:"readonly"`
}

type imagesOptions struct {
Expand Down Expand Up @@ -204,9 +206,9 @@ func (i imagesOptions) setOutputFormat() string {
if i.quiet {
return formats.IDString
}
format := "table {{.Repository}}\t{{.Tag}}\t"
format := "table {{.Repository}}\t{{if .Tag}}{{.Tag}}{{else}}<none>{{end}}\t"
if i.noHeading {
format = "{{.Repository}}\t{{.Tag}}\t"
format = "{{.Repository}}\t{{if .Tag}}{{.Tag}}{{else}}<none>{{end}}\t"
}
if i.digests {
format += "{{.Digest}}\t"
Expand Down Expand Up @@ -268,7 +270,7 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
imageID = shortID(img.ID())
}

// get all specified repo:tag pairs and print them separately
// get all specified repo:tag and repo@digest pairs and print them separately
repopairs, err := image.ReposToMap(img.Names())
if err != nil {
logrus.Errorf("error finding tag/digest for %s", img.ID())
Expand All @@ -285,11 +287,17 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
lastNumIdx := strings.LastIndexFunc(sizeStr, unicode.IsNumber)
sizeStr = sizeStr[:lastNumIdx+1] + " " + sizeStr[lastNumIdx+1:]
}
var imageDigest digest.Digest
if len(tag) == 71 && strings.HasPrefix(tag, "sha256:") {
imageDigest = digest.Digest(tag)
tag = ""
}
params := imagesTemplateParams{
Repository: repo,
Tag: tag,
ID: imageID,
Digest: img.Digest(),
Digest: imageDigest,
Digests: img.Digests(),
CreatedTime: createdTime,
Created: units.HumanDuration(time.Since(createdTime)) + " ago",
Size: sizeStr,
Expand All @@ -299,7 +307,6 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
if opts.quiet { // Show only one image ID when quiet
break outer
}

}
}
}
Expand All @@ -321,6 +328,7 @@ func getImagesJSONOutput(ctx context.Context, images []*adapter.ContainerImage)
ID: img.ID(),
Name: img.Names(),
Digest: img.Digest(),
Digests: img.Digests(),
Created: img.Created(),
Size: size,
ReadOnly: img.IsReadOnly(),
Expand Down
17 changes: 9 additions & 8 deletions cmd/podman/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"os"
"strings"

"github.com/containers/image/v4/docker"
"github.com/containers/image/v4/pkg/docker/config"
"github.com/containers/image/v4/types"
"github.com/containers/image/v5/docker"
"github.com/containers/image/v5/pkg/docker/config"
"github.com/containers/image/v5/types"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod/image"
"github.com/docker/docker-credential-helpers/credentials"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
)
Expand Down Expand Up @@ -134,15 +135,15 @@ func loginCmd(c *cliconfig.LoginValues) error {
return err
}
}
switch err {
case nil:
if err == nil {
fmt.Println("Login Succeeded!")
return nil
case docker.ErrUnauthorizedForCredentials:
}
if unauthorizedError, ok := err.(docker.ErrUnauthorizedForCredentials); ok {
logrus.Debugf("error logging into %q: %v", server, unauthorizedError)
return errors.Errorf("error logging into %q: invalid username/password", server)
default:
return errors.Wrapf(err, "error authenticating creds for %q", server)
}
return errors.Wrapf(err, "error authenticating creds for %q", server)
}

// getUserAndPass gets the username and password from STDIN if not given
Expand Down
4 changes: 2 additions & 2 deletions cmd/podman/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"fmt"

"github.com/containers/image/v4/docker"
"github.com/containers/image/v4/pkg/docker/config"
"github.com/containers/image/v5/docker"
"github.com/containers/image/v5/pkg/docker/config"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod/image"
Expand Down
14 changes: 10 additions & 4 deletions cmd/podman/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"os"
"strings"

"github.com/containers/image/v4/docker"
dockerarchive "github.com/containers/image/v4/docker/archive"
"github.com/containers/image/v4/transports/alltransports"
"github.com/containers/image/v4/types"
"github.com/containers/image/v5/docker"
dockerarchive "github.com/containers/image/v5/docker/archive"
"github.com/containers/image/v5/transports/alltransports"
"github.com/containers/image/v5/types"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod/image"
Expand Down Expand Up @@ -54,6 +54,10 @@ func init() {
flags.BoolVar(&pullCommand.AllTags, "all-tags", false, "All tagged images in the repository will be pulled")
flags.StringVar(&pullCommand.Creds, "creds", "", "`Credentials` (USERNAME:PASSWORD) to use for authenticating to a registry")
flags.BoolVarP(&pullCommand.Quiet, "quiet", "q", false, "Suppress output information when pulling images")
flags.StringVar(&pullCommand.OverrideArch, "override-arch", "", "use `ARCH` instead of the architecture of the machine for choosing images")
markFlagHidden(flags, "override-arch")
flags.StringVar(&pullCommand.OverrideOS, "override-os", "", "use `OS` instead of the running OS for choosing images")
markFlagHidden(flags, "override-os")
// Disabled flags for the remote client
if !remote {
flags.StringVar(&pullCommand.Authfile, "authfile", shared.GetAuthFile(""), "Path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override")
Expand Down Expand Up @@ -122,6 +126,8 @@ func pullCmd(c *cliconfig.PullValues) (retError error) {
dockerRegistryOptions := image.DockerRegistryOptions{
DockerRegistryCreds: registryCreds,
DockerCertPath: c.CertDir,
OSChoice: c.OverrideOS,
ArchitectureChoice: c.OverrideArch,
}
if c.IsSet("tls-verify") {
dockerRegistryOptions.DockerInsecureSkipTLSVerify = types.NewOptionalBool(!c.TlsVerify)
Expand Down
6 changes: 3 additions & 3 deletions cmd/podman/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"os"
"strings"

"github.com/containers/image/v4/directory"
"github.com/containers/image/v4/manifest"
"github.com/containers/image/v4/types"
"github.com/containers/image/v5/directory"
"github.com/containers/image/v5/manifest"
"github.com/containers/image/v5/types"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod/image"
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/runlabel.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"strings"

"github.com/containers/image/v4/types"
"github.com/containers/image/v5/types"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/cmd/podman/shared"
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"

"github.com/containers/buildah/pkg/formats"
"github.com/containers/image/v4/types"
"github.com/containers/image/v5/types"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod/image"
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/shared/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"sync"
"time"

"github.com/containers/image/v4/types"
"github.com/containers/image/v5/types"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/libpod/image"
Expand Down
26 changes: 11 additions & 15 deletions cmd/podman/shared/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"syscall"
"time"

"github.com/containers/image/v4/manifest"
"github.com/containers/image/v5/manifest"
"github.com/containers/libpod/cmd/podman/shared/parse"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/libpod/image"
Expand Down Expand Up @@ -89,7 +89,12 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
return nil, nil, err
}

newImage, err := runtime.ImageRuntime().New(ctx, name, rtc.SignaturePolicyPath, GetAuthFile(c.String("authfile")), writer, nil, image.SigningOptions{}, nil, pullType)
dockerRegistryOptions := image.DockerRegistryOptions{
OSChoice: c.String("override-os"),
ArchitectureChoice: c.String("override-arch"),
}

newImage, err := runtime.ImageRuntime().New(ctx, name, rtc.SignaturePolicyPath, GetAuthFile(c.String("authfile")), writer, &dockerRegistryOptions, image.SigningOptions{}, nil, pullType)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -246,19 +251,10 @@ func parseSecurityOpt(config *cc.CreateConfig, securityOpts []string, runtime *l
}

if config.SeccompProfilePath == "" {
if _, err := os.Stat(libpod.SeccompOverridePath); err == nil {
config.SeccompProfilePath = libpod.SeccompOverridePath
} else {
if !os.IsNotExist(err) {
return errors.Wrapf(err, "can't check if %q exists", libpod.SeccompOverridePath)
}
if _, err := os.Stat(libpod.SeccompDefaultPath); err != nil {
if !os.IsNotExist(err) {
return errors.Wrapf(err, "can't check if %q exists", libpod.SeccompDefaultPath)
}
} else {
config.SeccompProfilePath = libpod.SeccompDefaultPath
}
var err error
config.SeccompProfilePath, err = libpod.DefaultSeccompPath()
if err != nil {
return err
}
}
config.LabelOpts = labelOpts
Expand Down
2 changes: 2 additions & 0 deletions cmd/podman/shared/intermediate.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ func NewIntermediateLayer(c *cliconfig.PodmanCommand, remote bool) GenericCLIRes
m["no-hosts"] = newCRBool(c, "no-hosts")
m["oom-kill-disable"] = newCRBool(c, "oom-kill-disable")
m["oom-score-adj"] = newCRInt(c, "oom-score-adj")
m["override-arch"] = newCRString(c, "override-arch")
m["override-os"] = newCRString(c, "override-os")
m["pid"] = newCRString(c, "pid")
m["pids-limit"] = newCRInt64(c, "pids-limit")
m["pod"] = newCRString(c, "pod")
Expand Down
4 changes: 4 additions & 0 deletions cmd/podman/shared/intermediate_varlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ func (g GenericCLIResults) MakeVarlink() iopodman.Create {
Network: StringToPtr(g.Find("network")),
OomKillDisable: BoolToPtr(g.Find("oom-kill-disable")),
OomScoreAdj: AnyIntToInt64Ptr(g.Find("oom-score-adj")),
OverrideOS: StringToPtr(g.Find("override-os")),
OverrideArch: StringToPtr(g.Find("override-arch")),
Pid: StringToPtr(g.Find("pid")),
PidsLimit: AnyIntToInt64Ptr(g.Find("pids-limit")),
Pod: StringToPtr(g.Find("pod")),
Expand Down Expand Up @@ -389,6 +391,8 @@ func VarlinkCreateToGeneric(opts iopodman.Create) GenericCLIResults {
m["no-hosts"] = boolFromVarlink(opts.NoHosts, "no-hosts", false)
m["oom-kill-disable"] = boolFromVarlink(opts.OomKillDisable, "oon-kill-disable", false)
m["oom-score-adj"] = intFromVarlink(opts.OomScoreAdj, "oom-score-adj", nil)
m["override-os"] = stringFromVarlink(opts.OverrideOS, "override-os", nil)
m["override-arch"] = stringFromVarlink(opts.OverrideArch, "override-arch", nil)
m["pid"] = stringFromVarlink(opts.Pid, "pid", nil)
m["pids-limit"] = int64FromVarlink(opts.PidsLimit, "pids-limit", nil)
m["pod"] = stringFromVarlink(opts.Pod, "pod", nil)
Expand Down
6 changes: 3 additions & 3 deletions cmd/podman/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"strconv"
"strings"

"github.com/containers/image/v4/signature"
"github.com/containers/image/v4/transports"
"github.com/containers/image/v4/transports/alltransports"
"github.com/containers/image/v5/signature"
"github.com/containers/image/v5/transports"
"github.com/containers/image/v5/transports/alltransports"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod/image"
Expand Down
5 changes: 4 additions & 1 deletion cmd/podman/varlink/io.podman.varlink
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ type VolumeRemoveOpts (

type Image (
id: string,
digest: string,
digest: string,
digests: []string,
parentId: string,
repoTags: []string,
repoDigests: []string,
Expand Down Expand Up @@ -342,6 +343,8 @@ type Create (
noHosts: ?bool,
oomKillDisable: ?bool,
oomScoreAdj: ?int,
overrideArch: ?string,
overrideOS: ?string,
pid: ?string,
pidsLimit: ?int,
pod: ?string,
Expand Down
2 changes: 1 addition & 1 deletion contrib/perftest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"text/tabwriter"
"time"

"github.com/containers/image/v4/types"
"github.com/containers/image/v5/types"
"github.com/containers/libpod/libpod"
image2 "github.com/containers/libpod/libpod/image"
cc "github.com/containers/libpod/pkg/spec"
Expand Down
Loading