mirror of
https://github.com/containers/podman.git
synced 2025-12-05 04:40:47 +08:00
Merge pull request #3800 from vrothberg/generate-pod
generate systemd pod
This commit is contained in:
@@ -156,6 +156,7 @@ type GenerateKubeValues struct {
|
||||
type GenerateSystemdValues struct {
|
||||
PodmanCommand
|
||||
Name bool
|
||||
Files bool
|
||||
RestartPolicy string
|
||||
StopTimeout int
|
||||
}
|
||||
|
||||
@@ -18,11 +18,14 @@ var (
|
||||
// Commands that are universally implemented
|
||||
generateCommands = []*cobra.Command{
|
||||
_containerKubeCommand,
|
||||
_containerSystemdCommand,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Systemd-service generation is not supported for remote-clients.
|
||||
if !remoteclient {
|
||||
generateCommands = append(generateCommands, _containerSystemdCommand)
|
||||
}
|
||||
generateCommand.Command = _generateCommand
|
||||
generateCommand.AddCommand(generateCommands...)
|
||||
generateCommand.SetUsageTemplate(UsageTemplate())
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/containers/libpod/cmd/podman/cliconfig"
|
||||
"github.com/containers/libpod/pkg/adapter"
|
||||
"github.com/containers/libpod/pkg/systemdgen"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -40,7 +39,10 @@ func init() {
|
||||
containerSystemdCommand.SetHelpTemplate(HelpTemplate())
|
||||
containerSystemdCommand.SetUsageTemplate(UsageTemplate())
|
||||
flags := containerSystemdCommand.Flags()
|
||||
flags.BoolVarP(&containerSystemdCommand.Name, "name", "n", false, "use the container name instead of ID")
|
||||
flags.BoolVarP(&containerSystemdCommand.Name, "name", "n", false, "use the container/pod name instead of ID")
|
||||
if !remoteclient {
|
||||
flags.BoolVarP(&containerSystemdCommand.Files, "files", "f", false, "generate files instead of printing to stdout")
|
||||
}
|
||||
flags.IntVarP(&containerSystemdCommand.StopTimeout, "timeout", "t", -1, "stop timeout override")
|
||||
flags.StringVar(&containerSystemdCommand.RestartPolicy, "restart-policy", "on-failure", "applicable systemd restart-policy")
|
||||
}
|
||||
@@ -56,10 +58,6 @@ func generateSystemdCmd(c *cliconfig.GenerateSystemdValues) error {
|
||||
if c.Flag("timeout").Changed && c.StopTimeout < 0 {
|
||||
return errors.New("timeout value must be 0 or greater")
|
||||
}
|
||||
// Make sure the input restart policy is valid
|
||||
if err := systemdgen.ValidateRestartPolicy(c.RestartPolicy); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
unit, err := runtime.GenerateSystemd(c)
|
||||
if err != nil {
|
||||
|
||||
@@ -1241,8 +1241,6 @@ method GetLayersMapWithImageInfo() -> (layerMap: string)
|
||||
# BuildImageHierarchyMap is for the development of Podman and should not be used.
|
||||
method BuildImageHierarchyMap(name: string) -> (imageInfo: string)
|
||||
|
||||
method GenerateSystemd(name: string, restart: string, timeout: int, useName: bool) -> (unit: string)
|
||||
|
||||
# ImageNotFound means the image could not be found by the provided name or ID in local storage.
|
||||
error ImageNotFound (id: string, reason: string)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user