summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod/play.go
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2021-04-15 17:42:05 +0200
committerPaul Holzinger <paul.holzinger@web.de>2021-04-16 09:55:03 +0200
commitd7292dbf2731701c122656400ce5007693efe3c8 (patch)
tree0e221dc5d6360abf7226e8e8428f5b7e7149cc11 /pkg/api/handlers/libpod/play.go
parentb074e80351de2be0ea2888ac54f92bc542209a36 (diff)
downloadpodman-d7292dbf2731701c122656400ce5007693efe3c8.tar.gz
podman-d7292dbf2731701c122656400ce5007693efe3c8.tar.bz2
podman-d7292dbf2731701c122656400ce5007693efe3c8.zip
add --ip to podman play kube
Add a new --ip flag to podman play kube. This is used to specify a static IP address which should be used for the pod. This option can be specified several times because play kube can create more than one pod. Fixes #8442 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'pkg/api/handlers/libpod/play.go')
-rw-r--r--pkg/api/handlers/libpod/play.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/pkg/api/handlers/libpod/play.go b/pkg/api/handlers/libpod/play.go
index eba5386b6..96f572a8b 100644
--- a/pkg/api/handlers/libpod/play.go
+++ b/pkg/api/handlers/libpod/play.go
@@ -3,6 +3,7 @@ package libpod
import (
"io"
"io/ioutil"
+ "net"
"net/http"
"os"
@@ -20,10 +21,11 @@ func PlayKube(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value("runtime").(*libpod.Runtime)
decoder := r.Context().Value("decoder").(*schema.Decoder)
query := struct {
- Network string `schema:"network"`
- TLSVerify bool `schema:"tlsVerify"`
- LogDriver string `schema:"logDriver"`
- Start bool `schema:"start"`
+ Network string `schema:"network"`
+ TLSVerify bool `schema:"tlsVerify"`
+ LogDriver string `schema:"logDriver"`
+ Start bool `schema:"start"`
+ StaticIPs []string `schema:"staticIPs"`
}{
TLSVerify: true,
Start: true,
@@ -35,6 +37,17 @@ func PlayKube(w http.ResponseWriter, r *http.Request) {
return
}
+ staticIPs := make([]net.IP, 0, len(query.StaticIPs))
+ for _, ipString := range query.StaticIPs {
+ ip := net.ParseIP(ipString)
+ if ip == nil {
+ utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
+ errors.Errorf("Invalid IP address %s", ipString))
+ return
+ }
+ staticIPs = append(staticIPs, ip)
+ }
+
// Fetch the K8s YAML file from the body, and copy it to a temp file.
tmpfile, err := ioutil.TempFile("", "libpod-play-kube.yml")
if err != nil {
@@ -71,6 +84,7 @@ func PlayKube(w http.ResponseWriter, r *http.Request) {
Network: query.Network,
Quiet: true,
LogDriver: query.LogDriver,
+ StaticIPs: staticIPs,
}
if _, found := r.URL.Query()["tlsVerify"]; found {
options.SkipTLSVerify = types.NewOptionalBool(!query.TLSVerify)