diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-04-17 05:52:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-17 05:52:51 -0400 |
commit | 676c33f07950b29b657370df5e767452692be648 (patch) | |
tree | 4a3ba7067472b1c3a9f1756f54a18816f84dd603 /pkg/api/handlers/libpod/play.go | |
parent | 35b62ef19f307fb365eb7a8734e456160f7b22a8 (diff) | |
parent | d7292dbf2731701c122656400ce5007693efe3c8 (diff) | |
download | podman-676c33f07950b29b657370df5e767452692be648.tar.gz podman-676c33f07950b29b657370df5e767452692be648.tar.bz2 podman-676c33f07950b29b657370df5e767452692be648.zip |
Merge pull request #10043 from Luap99/play-kube-ip
add --ip to podman play kube
Diffstat (limited to 'pkg/api/handlers/libpod/play.go')
-rw-r--r-- | pkg/api/handlers/libpod/play.go | 22 |
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) |