summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-05-12 13:35:56 -0400
committerGitHub <noreply@github.com>2022-05-12 13:35:56 -0400
commit81fc9f1deae7e92a298f3aee3a87cc4362123ea9 (patch)
treec54c4383181dd499f9e22334ca1ece71a20dabff /libpod/options.go
parent45e9f1ff097adca65a5bb2a7367883508900667d (diff)
parent840c120c21124de921a7f57435cf0d0497103736 (diff)
downloadpodman-81fc9f1deae7e92a298f3aee3a87cc4362123ea9.tar.gz
podman-81fc9f1deae7e92a298f3aee3a87cc4362123ea9.tar.bz2
podman-81fc9f1deae7e92a298f3aee3a87cc4362123ea9.zip
Merge pull request #14159 from vrothberg/service-container
play kube: service container
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go38
1 files changed, 37 insertions, 1 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 9b83cb76a..feb89510f 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -1,6 +1,7 @@
package libpod
import (
+ "fmt"
"net"
"os"
"path/filepath"
@@ -1477,7 +1478,7 @@ func WithCreateCommand(cmd []string) CtrCreateOption {
}
}
-// withIsInfra allows us to dfferentiate between infra containers and regular containers
+// withIsInfra allows us to dfferentiate between infra containers and other containers
// within the container config
func withIsInfra() CtrCreateOption {
return func(ctr *Container) error {
@@ -1491,6 +1492,20 @@ func withIsInfra() CtrCreateOption {
}
}
+// WithIsService allows us to dfferentiate between service containers and other container
+// within the container config
+func WithIsService() CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return define.ErrCtrFinalized
+ }
+
+ ctr.config.IsService = true
+
+ return nil
+ }
+}
+
// WithCreateWorkingDir tells Podman to create the container's working directory
// if it does not exist.
func WithCreateWorkingDir() CtrCreateOption {
@@ -2081,6 +2096,27 @@ func WithInfraContainer() PodCreateOption {
}
}
+// WithServiceContainer associates the specified service container ID with the pod.
+func WithServiceContainer(id string) PodCreateOption {
+ return func(pod *Pod) error {
+ if pod.valid {
+ return define.ErrPodFinalized
+ }
+
+ ctr, err := pod.runtime.LookupContainer(id)
+ if err != nil {
+ return fmt.Errorf("looking up service container: %w", err)
+ }
+
+ if err := ctr.addServicePodLocked(pod.ID()); err != nil {
+ return fmt.Errorf("associating service container %s with pod %s: %w", id, pod.ID(), err)
+ }
+
+ pod.config.ServiceContainerID = id
+ return nil
+ }
+}
+
// WithVolatile sets the volatile flag for the container storage.
// The option can potentially cause data loss when used on a container that must survive a machine reboot.
func WithVolatile() CtrCreateOption {