summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cirrus.yml36
-rwxr-xr-xAPI.md66
-rw-r--r--cmd/podman/commands.go2
-rw-r--r--cmd/podman/container.go2
-rwxr-xr-xhack/tree_status.sh4
-rw-r--r--pkg/systemdgen/systemdgen_test.go120
6 files changed, 226 insertions, 4 deletions
diff --git a/.cirrus.yml b/.cirrus.yml
index 0745b1e7b..514889969 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -176,10 +176,40 @@ vendor_task:
failed_master_script: '$CIRRUS_WORKING_DIR/$SCRIPT_BASE/notice_master_failure.sh |& ${TIMESTAMP}'
+# This task runs `make varlink_api_generate` followed by ./hack/tree_status.sh to check
+# whether the git tree is clean.
+varlink_api_task:
+
+ depends_on:
+ - "gating"
+
+ env:
+ CIRRUS_WORKING_DIR: "/usr/src/libpod"
+ # Used by tree_status.sh
+ SUGGESTION: 'remove API.md, then "make varlink_api_generate" and commit changes.'
+
+ # Runs within Cirrus's "community cluster"
+ container:
+ image: "quay.io/libpod/gate:latest"
+ cpu: 4
+ memory: 12
+
+ timeout_in: 10m
+
+ vendor_script:
+ - '/usr/local/bin/entrypoint.sh varlink_api_generate'
+ - 'cd /go/src/github.com/containers/libpod && ./hack/tree_status.sh'
+
+ on_failure:
+ failed_master_script: '$CIRRUS_WORKING_DIR/$SCRIPT_BASE/notice_master_failure.sh'
+
+
build_each_commit_task:
depends_on:
- "gating"
+ - "vendor"
+ - "varlink_api"
# $CIRRUS_BASE_BRANCH is only set when testing a PR
only_if: $CIRRUS_BRANCH != 'master'
@@ -232,6 +262,8 @@ testing_task:
depends_on:
- "gating"
+ - "varlink_api"
+ - "vendor"
- "build_each_commit"
gce_instance:
@@ -275,6 +307,8 @@ special_testing_task:
depends_on:
- "gating"
+ - "varlink_api"
+ - "vendor"
- "build_each_commit"
gce_instance:
@@ -388,6 +422,8 @@ success_task:
depends_on: # ignores any dependent task conditions
- "gating"
+ - "varlink_api"
+ - "vendor"
- "build_each_commit_task"
- "testing"
- "rootless_testing_task"
diff --git a/API.md b/API.md
index 738449f43..11b9a462f 100755
--- a/API.md
+++ b/API.md
@@ -45,6 +45,10 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in
[func ExportImage(name: string, destination: string, compress: bool, tags: []string) string](#ExportImage)
+[func GenerateKube(name: string, service: bool) KubePodService](#GenerateKube)
+
+[func GenerateSystemd(name: string, restart: string, timeout: int, useName: bool) string](#GenerateSystemd)
+
[func GetAttachSockets(name: string) Sockets](#GetAttachSockets)
[func GetContainer(id: string) Container](#GetContainer)
@@ -57,6 +61,8 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in
[func GetContainersByContext(all: bool, latest: bool, args: []string) []string](#GetContainersByContext)
+[func GetContainersByStatus(status: []string) Container](#GetContainersByStatus)
+
[func GetContainersLogs(names: []string, follow: bool, latest: bool, since: string, tail: int, timestamps: bool) LogLine](#GetContainersLogs)
[func GetEvents(filter: []string, since: string, until: string) Event](#GetEvents)
@@ -73,6 +79,8 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in
[func GetPodsByContext(all: bool, latest: bool, args: []string) []string](#GetPodsByContext)
+[func GetPodsByStatus(statuses: []string) []string](#GetPodsByStatus)
+
[func GetVersion() string, string, string, string, string, int](#GetVersion)
[func GetVolumes(args: []string, all: bool) Volume](#GetVolumes)
@@ -87,6 +95,8 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in
[func ImportImage(source: string, reference: string, message: string, changes: []string, delete: bool) string](#ImportImage)
+[func InitContainer(name: string) string](#InitContainer)
+
[func InspectContainer(name: string) string](#InspectContainer)
[func InspectImage(name: string) string](#InspectImage)
@@ -153,6 +163,8 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in
[func TagImage(name: string, tagged: string) string](#TagImage)
+[func Top(nameOrID: string, descriptors: []string) []string](#Top)
+
[func TopPod(pod: string, latest: bool, descriptors: []string) []string](#TopPod)
[func UnmountContainer(name: string, force: bool) ](#UnmountContainer)
@@ -211,6 +223,8 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in
[type InfoStore](#InfoStore)
+[type KubePodService](#KubePodService)
+
[type ListPodContainerInfo](#ListPodContainerInfo)
[type ListPodData](#ListPodData)
@@ -249,6 +263,8 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in
[error ImageNotFound](#ImageNotFound)
+[error InvalidState](#InvalidState)
+
[error NoContainerRunning](#NoContainerRunning)
[error NoContainersInPod](#NoContainersInPod)
@@ -445,6 +461,17 @@ a booleon option to force compression. It also takes in a string array of tags
tags of the same image to a tarball (each tag should be of the form <image>:<tag>). Upon completion, the ID
of the image is returned. If the image cannot be found in local storage, an [ImageNotFound](#ImageNotFound)
error will be returned. See also [ImportImage](ImportImage).
+### <a name="GenerateKube"></a>func GenerateKube
+<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
+
+method GenerateKube(name: [string](https://godoc.org/builtin#string), service: [bool](https://godoc.org/builtin#bool)) [KubePodService](#KubePodService)</div>
+GenerateKube generates a Kubernetes v1 Pod description of a Podman container or pod
+and its containers. The description is in YAML. See also [ReplayKube](ReplayKube).
+### <a name="GenerateSystemd"></a>func GenerateSystemd
+<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
+
+method GenerateSystemd(name: [string](https://godoc.org/builtin#string), restart: [string](https://godoc.org/builtin#string), timeout: [int](https://godoc.org/builtin#int), useName: [bool](https://godoc.org/builtin#bool)) [string](https://godoc.org/builtin#string)</div>
+
### <a name="GetAttachSockets"></a>func GetAttachSockets
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
@@ -522,6 +549,11 @@ method GetContainersByContext(all: [bool](https://godoc.org/builtin#bool), lates
GetContainersByContext allows you to get a list of container ids depending on all, latest, or a list of
container names. The definition of latest container means the latest by creation date. In a multi-
user environment, results might differ from what you expect.
+### <a name="GetContainersByStatus"></a>func GetContainersByStatus
+<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
+
+method GetContainersByStatus(status: [[]string](#[]string)) [Container](#Container)</div>
+
### <a name="GetContainersLogs"></a>func GetContainersLogs
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
@@ -621,6 +653,11 @@ method GetPodsByContext(all: [bool](https://godoc.org/builtin#bool), latest: [bo
GetPodsByContext allows you to get a list pod ids depending on all, latest, or a list of
pod names. The definition of latest pod means the latest by creation date. In a multi-
user environment, results might differ from what you expect.
+### <a name="GetPodsByStatus"></a>func GetPodsByStatus
+<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
+
+method GetPodsByStatus(statuses: [[]string](#[]string)) [[]string](#[]string)</div>
+GetPodsByStatus searches for pods whose status is included in statuses
### <a name="GetVersion"></a>func GetVersion
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
@@ -669,6 +706,16 @@ the IDs of the removed images are returned.
method ImportImage(source: [string](https://godoc.org/builtin#string), reference: [string](https://godoc.org/builtin#string), message: [string](https://godoc.org/builtin#string), changes: [[]string](#[]string), delete: [bool](https://godoc.org/builtin#bool)) [string](https://godoc.org/builtin#string)</div>
ImportImage imports an image from a source (like tarball) into local storage. The image can have additional
descriptions added to it using the message and changes options. See also [ExportImage](ExportImage).
+### <a name="InitContainer"></a>func InitContainer
+<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
+
+method InitContainer(name: [string](https://godoc.org/builtin#string)) [string](https://godoc.org/builtin#string)</div>
+InitContainer initializes the given container. It accepts a container name or
+ID, and will initialize the container matching that ID if possible, and error
+if not. Containers can only be initialized when they are in the Created or
+Exited states. Initialization prepares a container to be started, but does not
+start the container. It is intended to be used to debug a container's state
+prior to starting it.
### <a name="InspectContainer"></a>func InspectContainer
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
@@ -1039,6 +1086,11 @@ $ varlink call -m unix:/run/podman/io.podman/io.podman.StopPod '{"name": "135d71
method TagImage(name: [string](https://godoc.org/builtin#string), tagged: [string](https://godoc.org/builtin#string)) [string](https://godoc.org/builtin#string)</div>
TagImage takes the name or ID of an image in local storage as well as the desired tag name. If the image cannot
be found, an [ImageNotFound](#ImageNotFound) error will be returned; otherwise, the ID of the image is returned on success.
+### <a name="Top"></a>func Top
+<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
+
+method Top(nameOrID: [string](https://godoc.org/builtin#string), descriptors: [[]string](#[]string)) [[]string](#[]string)</div>
+
### <a name="TopPod"></a>func TopPod
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
@@ -1445,6 +1497,8 @@ quiet [](#)
readonly [](#)
+readonlytmpfs [](#)
+
restart [](#)
rm [](#)
@@ -1666,6 +1720,13 @@ graph_root [string](https://godoc.org/builtin#string)
graph_status [InfoGraphStatus](#InfoGraphStatus)
run_root [string](https://godoc.org/builtin#string)
+### <a name="KubePodService"></a>type KubePodService
+
+
+
+pod [string](https://godoc.org/builtin#string)
+
+service [string](https://godoc.org/builtin#string)
### <a name="ListPodContainerInfo"></a>type ListPodContainerInfo
ListPodContainerInfo is a returned struct for describing containers
@@ -1924,6 +1985,9 @@ is includes as part of the error's text.
### <a name="ImageNotFound"></a>type ImageNotFound
ImageNotFound means the image could not be found by the provided name or ID in local storage.
+### <a name="InvalidState"></a>type InvalidState
+
+InvalidState indicates that a container or pod was in an improper state for the requested operation
### <a name="NoContainerRunning"></a>type NoContainerRunning
NoContainerRunning means none of the containers requested are running in a command that requires a running container.
@@ -1933,7 +1997,7 @@ NoContainersInPod means a pod has no containers on which to perform the operatio
the pod ID.
### <a name="PodContainerError"></a>type PodContainerError
-PodContainerError means a container associated with a pod failed to preform an operation. It contains
+PodContainerError means a container associated with a pod failed to perform an operation. It contains
a container ID of the container that failed.
### <a name="PodNotFound"></a>type PodNotFound
diff --git a/cmd/podman/commands.go b/cmd/podman/commands.go
index 14451d944..3a409f503 100644
--- a/cmd/podman/commands.go
+++ b/cmd/podman/commands.go
@@ -39,13 +39,11 @@ func getImageSubCommands() []*cobra.Command {
func getContainerSubCommands() []*cobra.Command {
return []*cobra.Command{
- _checkpointCommand,
_cleanupCommand,
_commitCommand,
_execCommand,
_mountCommand,
_refreshCommand,
- _restoreCommand,
_runlabelCommand,
_statsCommand,
_umountCommand,
diff --git a/cmd/podman/container.go b/cmd/podman/container.go
index bbf01d1f8..530175a55 100644
--- a/cmd/podman/container.go
+++ b/cmd/podman/container.go
@@ -51,6 +51,7 @@ var (
// Commands that are universally implemented.
containerCommands = []*cobra.Command{
_attachCommand,
+ _checkpointCommand,
_containerExistsCommand,
_contInspectSubCommand,
_diffCommand,
@@ -64,6 +65,7 @@ var (
_portCommand,
_pruneContainersCommand,
_restartCommand,
+ _restoreCommand,
_runCommand,
_rmCommand,
_startCommand,
diff --git a/hack/tree_status.sh b/hack/tree_status.sh
index 78fb4c6a3..ac874a347 100755
--- a/hack/tree_status.sh
+++ b/hack/tree_status.sh
@@ -1,12 +1,14 @@
#!/bin/bash
set -e
+SUGGESTION="${SUGGESTION:-sync the vendor.conf and commit all changes.}"
+
STATUS=$(git status --porcelain)
if [[ -z $STATUS ]]
then
echo "tree is clean"
else
- echo "tree is dirty, please commit all changes and sync the vendor.conf"
+ echo "tree is dirty, please $SUGGESTION"
echo ""
echo "$STATUS"
exit 1
diff --git a/pkg/systemdgen/systemdgen_test.go b/pkg/systemdgen/systemdgen_test.go
new file mode 100644
index 000000000..f2f49e750
--- /dev/null
+++ b/pkg/systemdgen/systemdgen_test.go
@@ -0,0 +1,120 @@
+package systemdgen
+
+import (
+ "testing"
+)
+
+func TestValidateRestartPolicy(t *testing.T) {
+ type args struct {
+ restart string
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr bool
+ }{
+ {"good-on", args{restart: "no"}, false},
+ {"good-on-success", args{restart: "on-success"}, false},
+ {"good-on-failure", args{restart: "on-failure"}, false},
+ {"good-on-abnormal", args{restart: "on-abnormal"}, false},
+ {"good-on-watchdog", args{restart: "on-watchdog"}, false},
+ {"good-on-abort", args{restart: "on-abort"}, false},
+ {"good-always", args{restart: "always"}, false},
+ {"fail", args{restart: "foobar"}, true},
+ {"failblank", args{restart: ""}, true},
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if err := ValidateRestartPolicy(tt.args.restart); (err != nil) != tt.wantErr {
+ t.Errorf("ValidateRestartPolicy() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ })
+ }
+}
+
+func TestCreateSystemdUnitAsString(t *testing.T) {
+ goodID := `[Unit]
+Description=639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401 Podman Container
+[Service]
+Restart=always
+ExecStart=/usr/bin/podman start 639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401
+ExecStop=/usr/bin/podman stop -t 10 639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401
+KillMode=none
+Type=forking
+PIDFile=/var/lib/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.pid
+[Install]
+WantedBy=multi-user.target`
+
+ goodName := `[Unit]
+Description=foobar Podman Container
+[Service]
+Restart=always
+ExecStart=/usr/bin/podman start foobar
+ExecStop=/usr/bin/podman stop -t 10 foobar
+KillMode=none
+Type=forking
+PIDFile=/var/lib/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.pid
+[Install]
+WantedBy=multi-user.target`
+
+ type args struct {
+ name string
+ cid string
+ restart string
+ pidPath string
+ stopTimeout int
+ }
+ tests := []struct {
+ name string
+ args args
+ want string
+ wantErr bool
+ }{
+
+ {"good with id",
+ args{
+ "639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401",
+ "639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401",
+ "always",
+ "/var/lib/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/",
+ 10,
+ },
+ goodID,
+ false,
+ },
+ {"good with name",
+ args{
+ "foobar",
+ "639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401",
+ "always",
+ "/var/lib/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/",
+ 10,
+ },
+ goodName,
+ false,
+ },
+ {"bad restart policy",
+ args{
+ "639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401",
+ "639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401",
+ "never",
+ "/var/lib/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/",
+ 10,
+ },
+ "",
+ true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ got, err := CreateSystemdUnitAsString(tt.args.name, tt.args.cid, tt.args.restart, tt.args.pidPath, tt.args.stopTimeout)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("CreateSystemdUnitAsString() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if got != tt.want {
+ t.Errorf("CreateSystemdUnitAsString() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}