mirror of https://github.com/containers/podman.git
Merge pull request #14334 from rhatdan/pod1
Allow podman pod create to accept name argument
This commit is contained in:
commit
b13184dfb4
|
@ -16,7 +16,6 @@ import (
|
||||||
"github.com/containers/podman/v4/cmd/podman/containers"
|
"github.com/containers/podman/v4/cmd/podman/containers"
|
||||||
"github.com/containers/podman/v4/cmd/podman/parse"
|
"github.com/containers/podman/v4/cmd/podman/parse"
|
||||||
"github.com/containers/podman/v4/cmd/podman/registry"
|
"github.com/containers/podman/v4/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v4/cmd/podman/validate"
|
|
||||||
"github.com/containers/podman/v4/libpod/define"
|
"github.com/containers/podman/v4/libpod/define"
|
||||||
"github.com/containers/podman/v4/pkg/domain/entities"
|
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||||
"github.com/containers/podman/v4/pkg/errorhandling"
|
"github.com/containers/podman/v4/pkg/errorhandling"
|
||||||
|
@ -36,12 +35,14 @@ var (
|
||||||
You can then start it at any time with the podman pod start <pod_id> command. The pod will be created with the initial state 'created'.`
|
You can then start it at any time with the podman pod start <pod_id> command. The pod will be created with the initial state 'created'.`
|
||||||
|
|
||||||
createCommand = &cobra.Command{
|
createCommand = &cobra.Command{
|
||||||
Use: "create [options]",
|
Use: "create [options] [NAME]",
|
||||||
Args: validate.NoArgs,
|
Args: cobra.MaximumNArgs(1),
|
||||||
Short: "Create a new empty pod",
|
Short: "Create a new empty pod",
|
||||||
Long: podCreateDescription,
|
Long: podCreateDescription,
|
||||||
RunE: create,
|
RunE: create,
|
||||||
ValidArgsFunction: completion.AutocompleteNone,
|
ValidArgsFunction: completion.AutocompleteNone,
|
||||||
|
Example: `podman pod create
|
||||||
|
podman pod create --label foo=bar mypod`,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -115,6 +116,12 @@ func create(cmd *cobra.Command, args []string) error {
|
||||||
rawImageName string
|
rawImageName string
|
||||||
podName string
|
podName string
|
||||||
)
|
)
|
||||||
|
if len(args) > 0 {
|
||||||
|
if len(createOptions.Name) > 0 {
|
||||||
|
return fmt.Errorf("cannot specify --name and NAME at the same time")
|
||||||
|
}
|
||||||
|
createOptions.Name = args[0]
|
||||||
|
}
|
||||||
labelFile = infraOptions.LabelFile
|
labelFile = infraOptions.LabelFile
|
||||||
labels = infraOptions.Label
|
labels = infraOptions.Label
|
||||||
createOptions.Labels, err = parse.GetAllLabels(labelFile, labels)
|
createOptions.Labels, err = parse.GetAllLabels(labelFile, labels)
|
||||||
|
@ -128,7 +135,7 @@ func create(cmd *cobra.Command, args []string) error {
|
||||||
img := imageName
|
img := imageName
|
||||||
if !createOptions.Infra {
|
if !createOptions.Infra {
|
||||||
if cmd.Flag("no-hosts").Changed {
|
if cmd.Flag("no-hosts").Changed {
|
||||||
return fmt.Errorf("cannot specify no-hosts without an infra container")
|
return fmt.Errorf("cannot specify --no-hosts without an infra container")
|
||||||
}
|
}
|
||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
createOptions.Net, err = common.NetFlagsToNetOptions(nil, *flags)
|
createOptions.Net, err = common.NetFlagsToNetOptions(nil, *flags)
|
||||||
|
|
|
@ -17,6 +17,7 @@ var (
|
||||||
|
|
||||||
createCommand = &cobra.Command{
|
createCommand = &cobra.Command{
|
||||||
Use: "create [options] [NAME]",
|
Use: "create [options] [NAME]",
|
||||||
|
Args: cobra.MaximumNArgs(1),
|
||||||
Short: "Create a new volume",
|
Short: "Create a new volume",
|
||||||
Long: createDescription,
|
Long: createDescription,
|
||||||
RunE: create,
|
RunE: create,
|
||||||
|
@ -59,9 +60,6 @@ func create(cmd *cobra.Command, args []string) error {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if len(args) > 1 {
|
|
||||||
return errors.Errorf("too many arguments, create takes at most 1 argument")
|
|
||||||
}
|
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
createOpts.Name = args[0]
|
createOpts.Name = args[0]
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
podman\-network-create - Create a Podman network
|
podman\-network-create - Create a Podman network
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
**podman network create** [*options*] name
|
**podman network create** [*options*] [*name*]
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
Create a CNI-network configuration for use with Podman. By default, Podman creates a bridge connection.
|
Create a CNI-network configuration for use with Podman. By default, Podman creates a bridge connection.
|
||||||
|
|
|
@ -4,14 +4,15 @@
|
||||||
podman\-pod\-create - Create a new pod
|
podman\-pod\-create - Create a new pod
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
**podman pod create** [*options*]
|
**podman pod create** [*options*] [*name*]
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
|
|
||||||
Creates an empty pod, or unit of multiple containers, and prepares it to have
|
Creates an empty pod, or unit of multiple containers, and prepares it to have
|
||||||
containers added to it. The pod id is printed to STDOUT. You can then use
|
containers added to it. The pod can be created with a specific name. If a name
|
||||||
**podman create --pod `<pod_id|pod_name>` ...** to add containers to the pod, and
|
is not given a random name is generated. The pod id is printed to STDOUT. You
|
||||||
**podman pod start `<pod_id|pod_name>`** to start the pod.
|
can then use **podman create --pod `<pod_id|pod_name>` ...** to add containers
|
||||||
|
to the pod, and **podman pod start `<pod_id|pod_name>`** to start the pod.
|
||||||
|
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
|
@ -549,9 +550,11 @@ that data on the target.
|
||||||
```
|
```
|
||||||
$ podman pod create --name test
|
$ podman pod create --name test
|
||||||
|
|
||||||
|
$ podman pod create mypod
|
||||||
|
|
||||||
$ podman pod create --infra=false
|
$ podman pod create --infra=false
|
||||||
|
|
||||||
$ podman pod create --infra-command /top
|
$ podman pod create --infra-command /top toppod
|
||||||
|
|
||||||
$ podman pod create --publish 8443:443
|
$ podman pod create --publish 8443:443
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
podman\-volume\-create - Create a new volume
|
podman\-volume\-create - Create a new volume
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
**podman volume create** [*options*]
|
**podman volume create** [*options*] [*name*]
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
|
|
||||||
|
|
|
@ -387,20 +387,20 @@ EOF
|
||||||
is "$output" "false" "Default network sharing should be false"
|
is "$output" "false" "Default network sharing should be false"
|
||||||
run_podman pod rm test
|
run_podman pod rm test
|
||||||
|
|
||||||
run_podman pod create --name test --share ipc --network private
|
run_podman pod create --share ipc --network private test
|
||||||
run_podman pod inspect test --format {{.InfraConfig.HostNetwork}}
|
run_podman pod inspect test --format {{.InfraConfig.HostNetwork}}
|
||||||
is "$output" "false" "Private network sharing with only ipc should be false"
|
is "$output" "false" "Private network sharing with only ipc should be false"
|
||||||
run_podman pod rm test
|
run_podman pod rm test
|
||||||
|
|
||||||
run_podman pod create --name test --share net --network private
|
local name="$(random_string 10 | tr A-Z a-z)"
|
||||||
run_podman pod inspect test --format {{.InfraConfig.HostNetwork}}
|
run_podman pod create --name $name --share net --network private
|
||||||
|
run_podman pod inspect $name --format {{.InfraConfig.HostNetwork}}
|
||||||
is "$output" "false" "Private network sharing with only net should be false"
|
is "$output" "false" "Private network sharing with only net should be false"
|
||||||
run_podman pod rm test
|
|
||||||
|
|
||||||
run_podman pod create --name test --share net --network host
|
run_podman pod create --share net --network host --replace $name
|
||||||
run_podman pod inspect test --format {{.InfraConfig.HostNetwork}}
|
run_podman pod inspect $name --format {{.InfraConfig.HostNetwork}}
|
||||||
is "$output" "true" "Host network sharing with only net should be true"
|
is "$output" "true" "Host network sharing with only net should be true"
|
||||||
run_podman pod rm test
|
run_podman pod rm $name
|
||||||
|
|
||||||
run_podman pod create --name test --share ipc --network host
|
run_podman pod create --name test --share ipc --network host
|
||||||
run_podman pod inspect test --format {{.InfraConfig.HostNetwork}}
|
run_podman pod inspect test --format {{.InfraConfig.HostNetwork}}
|
||||||
|
|
Loading…
Reference in New Issue