summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/containers/create.go4
-rw-r--r--cmd/podman/images/build.go20
-rw-r--r--cmd/podman/images/list.go83
3 files changed, 55 insertions, 52 deletions
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go
index 6269ec781..45ce00c86 100644
--- a/cmd/podman/containers/create.go
+++ b/cmd/podman/containers/create.go
@@ -156,10 +156,6 @@ func replaceContainer(name string) error {
}
func createInit(c *cobra.Command) error {
- if c.Flag("privileged").Changed && c.Flag("security-opt").Changed {
- logrus.Warn("setting security options with --privileged has no effect")
- }
-
if c.Flag("shm-size").Changed {
cliVals.ShmSize = c.Flag("shm-size").Value.String()
}
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 2efc795cd..23bfcab79 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -9,6 +9,7 @@ import (
"github.com/containers/buildah/imagebuildah"
buildahCLI "github.com/containers/buildah/pkg/cli"
"github.com/containers/buildah/pkg/parse"
+ "github.com/containers/common/pkg/config"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
"github.com/containers/libpod/pkg/domain/entities"
@@ -396,16 +397,10 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
runtimeFlags = append(runtimeFlags, "--"+arg)
}
- // FIXME: the code below needs to be enabled (and adjusted) once the
- // global/root flags are supported.
-
- // conf, err := runtime.GetConfig()
- // if err != nil {
- // return err
- // }
- // if conf != nil && conf.Engine.CgroupManager == config.SystemdCgroupsManager {
- // runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
- // }
+ containerConfig := registry.PodmanConfig()
+ if containerConfig.Engine.CgroupManager == config.SystemdCgroupsManager {
+ runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
+ }
opts := imagebuildah.BuildOptions{
AddCapabilities: flags.CapAdd,
@@ -418,12 +413,13 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
CNIPluginPath: flags.CNIPlugInPath,
CommonBuildOpts: &buildah.CommonBuildOptions{
AddHost: flags.AddHost,
- CgroupParent: flags.CgroupParent,
CPUPeriod: flags.CPUPeriod,
CPUQuota: flags.CPUQuota,
- CPUShares: flags.CPUShares,
CPUSetCPUs: flags.CPUSetCPUs,
CPUSetMems: flags.CPUSetMems,
+ CPUShares: flags.CPUShares,
+ CgroupParent: flags.CgroupParent,
+ HTTPProxy: flags.HTTPProxy,
Memory: memoryLimit,
MemorySwap: memorySwap,
ShmSize: flags.ShmSize,
diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go
index 236ae15b4..b7a8b8911 100644
--- a/cmd/podman/images/list.go
+++ b/cmd/podman/images/list.go
@@ -98,57 +98,79 @@ func images(cmd *cobra.Command, args []string) error {
return err
}
+ imgs := sortImages(summaries)
switch {
case listFlag.quiet:
- return writeID(summaries)
+ return writeID(imgs)
case cmd.Flag("format").Changed && listFlag.format == "json":
- return writeJSON(summaries)
+ return writeJSON(imgs)
default:
- return writeTemplate(summaries)
+ return writeTemplate(imgs)
}
}
-func writeID(imageS []*entities.ImageSummary) error {
- var ids = map[string]struct{}{}
- for _, e := range imageS {
- i := "sha256:" + e.ID
- if !listFlag.noTrunc {
- i = fmt.Sprintf("%12.12s", e.ID)
+func writeID(imgs []imageReporter) error {
+ lookup := make(map[string]struct{}, len(imgs))
+ ids := make([]string, 0)
+
+ for _, e := range imgs {
+ if _, found := lookup[e.ID()]; !found {
+ lookup[e.ID()] = struct{}{}
+ ids = append(ids, e.ID())
}
- ids[i] = struct{}{}
}
- for k := range ids {
- fmt.Fprint(os.Stdout, k+"\n")
+ for _, k := range ids {
+ fmt.Println(k)
}
return nil
}
-func writeJSON(imageS []*entities.ImageSummary) error {
+func writeJSON(images []imageReporter) error {
type image struct {
entities.ImageSummary
Created string
CreatedAt string
}
- imgs := make([]image, 0, len(imageS))
- for _, e := range imageS {
+ imgs := make([]image, 0, len(images))
+ for _, e := range images {
var h image
- h.ImageSummary = *e
- h.Created = units.HumanDuration(time.Since(e.Created)) + " ago"
- h.CreatedAt = e.Created.Format(time.RFC3339Nano)
+ h.ImageSummary = e.ImageSummary
+ h.Created = units.HumanDuration(time.Since(e.ImageSummary.Created)) + " ago"
+ h.CreatedAt = e.ImageSummary.Created.Format(time.RFC3339Nano)
h.RepoTags = nil
imgs = append(imgs, h)
}
- enc := json.NewEncoder(os.Stdout)
- return enc.Encode(imgs)
+ prettyJSON, err := json.MarshalIndent(imgs, "", " ")
+ if err != nil {
+ return err
+ }
+ fmt.Println(string(prettyJSON))
+ return nil
}
-func writeTemplate(imageS []*entities.ImageSummary) error {
+func writeTemplate(imgs []imageReporter) error {
var (
hdr, row string
)
+ if len(listFlag.format) < 1 {
+ hdr, row = imageListFormat(listFlag)
+ } else {
+ row = listFlag.format
+ if !strings.HasSuffix(row, "\n") {
+ row += "\n"
+ }
+ }
+ format := hdr + "{{range . }}" + row + "{{end}}"
+ tmpl := template.Must(template.New("list").Parse(format))
+ w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
+ defer w.Flush()
+ return tmpl.Execute(w, imgs)
+}
+
+func sortImages(imageS []*entities.ImageSummary) []imageReporter {
imgs := make([]imageReporter, 0, len(imageS))
for _, e := range imageS {
var h imageReporter
@@ -167,24 +189,11 @@ func writeTemplate(imageS []*entities.ImageSummary) error {
}
sort.Slice(imgs, sortFunc(listFlag.sort, imgs))
-
- if len(listFlag.format) < 1 {
- hdr, row = imageListFormat(listFlag)
- } else {
- row = listFlag.format
- if !strings.HasSuffix(row, "\n") {
- row += "\n"
- }
- }
- format := hdr + "{{range . }}" + row + "{{end}}"
- tmpl := template.Must(template.New("list").Parse(format))
- w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
- defer w.Flush()
- return tmpl.Execute(w, imgs)
+ return imgs
}
func tokenRepoTag(tag string) (string, string) {
- tokens := strings.SplitN(tag, ":", 2)
+ tokens := strings.Split(tag, ":")
switch len(tokens) {
case 0:
return tag, ""
@@ -192,6 +201,8 @@ func tokenRepoTag(tag string) (string, string) {
return tokens[0], ""
case 2:
return tokens[0], tokens[1]
+ case 3:
+ return tokens[0] + ":" + tokens[1], tokens[2]
default:
return "<N/A>", ""
}