diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/api/handlers/libpod/play.go | 5 | ||||
-rw-r--r-- | pkg/api/server/register_play.go | 5 | ||||
-rw-r--r-- | pkg/bindings/play/play.go | 3 | ||||
-rw-r--r-- | pkg/domain/entities/play.go | 2 | ||||
-rw-r--r-- | pkg/domain/infra/abi/play.go | 26 |
5 files changed, 29 insertions, 12 deletions
diff --git a/pkg/api/handlers/libpod/play.go b/pkg/api/handlers/libpod/play.go index 0c7a6e19d..42ff26a57 100644 --- a/pkg/api/handlers/libpod/play.go +++ b/pkg/api/handlers/libpod/play.go @@ -23,8 +23,10 @@ func PlayKube(w http.ResponseWriter, r *http.Request) { Network string `schema:"reference"` TLSVerify bool `schema:"tlsVerify"` LogDriver string `schema:"logDriver"` + Start bool `schema:"start"` }{ TLSVerify: true, + Start: true, } if err := decoder.Decode(&query, r.URL.Query()); err != nil { @@ -73,6 +75,9 @@ func PlayKube(w http.ResponseWriter, r *http.Request) { if _, found := r.URL.Query()["tlsVerify"]; found { options.SkipTLSVerify = types.NewOptionalBool(!query.TLSVerify) } + if _, found := r.URL.Query()["start"]; found { + options.Start = types.NewOptionalBool(query.Start) + } report, err := containerEngine.PlayKube(r.Context(), tmpfile.Name(), options) if err != nil { diff --git a/pkg/api/server/register_play.go b/pkg/api/server/register_play.go index e41f8311d..6aa349a3b 100644 --- a/pkg/api/server/register_play.go +++ b/pkg/api/server/register_play.go @@ -29,6 +29,11 @@ func (s *APIServer) registerPlayHandlers(r *mux.Router) error { // name: logDriver // type: string // description: Logging driver for the containers in the pod. + // - in: query + // name: start + // type: boolean + // default: true + // description: Start the pod after creating it. // - in: body // name: request // description: Kubernetes YAML file. diff --git a/pkg/bindings/play/play.go b/pkg/bindings/play/play.go index b6e8048de..cfb40d74b 100644 --- a/pkg/bindings/play/play.go +++ b/pkg/bindings/play/play.go @@ -32,6 +32,9 @@ func Kube(ctx context.Context, path string, options entities.PlayKubeOptions) (* if options.SkipTLSVerify != types.OptionalBoolUndefined { params.Set("tlsVerify", strconv.FormatBool(options.SkipTLSVerify != types.OptionalBoolTrue)) } + if options.Start != types.OptionalBoolUndefined { + params.Set("start", strconv.FormatBool(options.Start == types.OptionalBoolTrue)) + } // TODO: have a global system context we can pass around (1st argument) header, err := auth.Header(nil, auth.XRegistryAuthHeader, options.Authfile, options.Username, options.Password) diff --git a/pkg/domain/entities/play.go b/pkg/domain/entities/play.go index 7e4afcc28..0b42e1a3f 100644 --- a/pkg/domain/entities/play.go +++ b/pkg/domain/entities/play.go @@ -28,6 +28,8 @@ type PlayKubeOptions struct { ConfigMaps []string // LogDriver for the container. For example: journald LogDriver string + // Start - don't start the pod if false + Start types.OptionalBool } // PlayKubePod represents a single pod and associated containers created by play kube diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index c0948e099..4bcc6469c 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -297,20 +297,22 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY containers = append(containers, ctr) } - //start the containers - podStartErrors, err := pod.Start(ctx) - if err != nil { - return nil, err - } + if options.Start != types.OptionalBoolFalse { + //start the containers + podStartErrors, err := pod.Start(ctx) + if err != nil { + return nil, err + } - // Previous versions of playkube started containers individually and then - // looked for errors. Because we now use the uber-Pod start call, we should - // iterate the map of possible errors and return one if there is a problem. This - // keeps the behavior the same + // Previous versions of playkube started containers individually and then + // looked for errors. Because we now use the uber-Pod start call, we should + // iterate the map of possible errors and return one if there is a problem. This + // keeps the behavior the same - for _, e := range podStartErrors { - if e != nil { - return nil, e + for _, e := range podStartErrors { + if e != nil { + return nil, e + } } } |