summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/auto-update.go46
-rw-r--r--cmd/podman/login.go1
-rw-r--r--cmd/podman/logout.go1
-rw-r--r--cmd/podman/pods/create.go47
4 files changed, 70 insertions, 25 deletions
diff --git a/cmd/podman/auto-update.go b/cmd/podman/auto-update.go
new file mode 100644
index 000000000..758cbbc6f
--- /dev/null
+++ b/cmd/podman/auto-update.go
@@ -0,0 +1,46 @@
+package main
+
+import (
+ "fmt"
+
+ "github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/containers/libpod/pkg/errorhandling"
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+)
+
+var (
+ autoUpdateDescription = `Auto update containers according to their auto-update policy.
+
+ Auto-update policies are specified with the "io.containers.autoupdate" label.
+ Note that this command is experimental.`
+ autoUpdateCommand = &cobra.Command{
+ Use: "auto-update [flags]",
+ Short: "Auto update containers according to their auto-update policy",
+ Long: autoUpdateDescription,
+ RunE: autoUpdate,
+ Example: `podman auto-update`,
+ }
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: autoUpdateCommand,
+ })
+}
+
+func autoUpdate(cmd *cobra.Command, args []string) error {
+ if len(args) > 0 {
+ // Backwards compat. System tests expext this error string.
+ return errors.Errorf("`%s` takes no arguments", cmd.CommandPath())
+ }
+ report, failures := registry.ContainerEngine().AutoUpdate(registry.GetContext())
+ if report != nil {
+ for _, unit := range report.Units {
+ fmt.Println(unit)
+ }
+ }
+ return errorhandling.JoinErrors(failures)
+}
diff --git a/cmd/podman/login.go b/cmd/podman/login.go
index 8413861f5..92f13d0e7 100644
--- a/cmd/podman/login.go
+++ b/cmd/podman/login.go
@@ -46,7 +46,6 @@ func init() {
// Podman flags.
flags.BoolVarP(&loginOptions.tlsVerify, "tls-verify", "", false, "Require HTTPS and verify certificates when contacting registries")
- flags.BoolVarP(&loginOptions.GetLoginSet, "get-login", "", false, "Return the current login user for the registry")
loginOptions.Stdin = os.Stdin
loginOptions.Stdout = os.Stdout
loginOptions.AcceptUnspecifiedRegistry = true
diff --git a/cmd/podman/logout.go b/cmd/podman/logout.go
index d0afc21b4..c016de8ae 100644
--- a/cmd/podman/logout.go
+++ b/cmd/podman/logout.go
@@ -37,7 +37,6 @@ func init() {
// Flags from the auth package.
flags.AddFlagSet(auth.GetLogoutFlags(&logoutOptions))
- logoutOptions.Stdin = os.Stdin
logoutOptions.Stdout = os.Stdout
logoutOptions.AcceptUnspecifiedRegistry = true
}
diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go
index 0a2016496..f97fa836a 100644
--- a/cmd/podman/pods/create.go
+++ b/cmd/podman/pods/create.go
@@ -17,6 +17,7 @@ import (
"github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -59,6 +60,14 @@ func init() {
flags.StringVarP(&createOptions.Hostname, "hostname", "", "", "Set a hostname to the pod")
flags.StringVar(&podIDFile, "pod-id-file", "", "Write the pod ID to the file")
flags.StringVar(&share, "share", createconfig.DefaultKernelNamespaces, "A comma delimited list of kernel namespaces the pod will share")
+ flags.SetNormalizeFunc(aliasNetworkFlag)
+}
+
+func aliasNetworkFlag(_ *pflag.FlagSet, name string) pflag.NormalizedName {
+ if name == "net" {
+ name = "network"
+ }
+ return pflag.NormalizedName(name)
}
func create(cmd *cobra.Command, args []string) error {
@@ -105,29 +114,21 @@ func create(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- netInput, err := cmd.Flags().GetString("network")
- if err != nil {
- return err
- }
- n := specgen.Namespace{}
- switch netInput {
- case "bridge":
- n.NSMode = specgen.Bridge
- case "host":
- n.NSMode = specgen.Host
- case "slip4netns":
- n.NSMode = specgen.Slirp
- default:
- if strings.HasPrefix(netInput, "container:") { // nolint
- split := strings.Split(netInput, ":")
- if len(split) != 2 {
- return errors.Errorf("invalid network paramater: %q", netInput)
- }
- n.NSMode = specgen.FromContainer
- n.Value = split[1]
- } else if strings.HasPrefix(netInput, "ns:") {
- return errors.New("the ns: network option is not supported for pods")
- } else {
+ if cmd.Flag("network").Changed {
+ netInput, err := cmd.Flags().GetString("network")
+ if err != nil {
+ return err
+ }
+ n := specgen.Namespace{}
+ switch netInput {
+ case "bridge":
+ n.NSMode = specgen.Bridge
+ case "host":
+ n.NSMode = specgen.Host
+ case "slirp4netns":
+ n.NSMode = specgen.Slirp
+ default:
+ // Container and NS mode are presently unsupported
n.NSMode = specgen.Bridge
createOptions.Net.CNINetworks = strings.Split(netInput, ",")
}