From e08a77ce64eec5cd0192ae1970fa859c00440174 Mon Sep 17 00:00:00 2001 From: Niall Crowe Date: Fri, 24 Jun 2022 15:43:05 +0100 Subject: Add "podman kube play" cmd The "podman kube play" command is designed to be a replacement for the "podman play kube" command. It performs the same function as "play kube" while also still working with the same flags and options. The "podman play kube" command is still functional as an alias of "kube play". Closes #12475 Signed-off-by: Niall Crowe Signed-off-by: Valentin Rothberg --- pkg/api/server/register_kube.go | 82 +++++++++++++++++++++++++++++++++++++++++ pkg/api/server/register_play.go | 80 ---------------------------------------- pkg/api/server/server.go | 2 +- 3 files changed, 83 insertions(+), 81 deletions(-) create mode 100644 pkg/api/server/register_kube.go delete mode 100644 pkg/api/server/register_play.go (limited to 'pkg/api/server') diff --git a/pkg/api/server/register_kube.go b/pkg/api/server/register_kube.go new file mode 100644 index 000000000..6ae9e8123 --- /dev/null +++ b/pkg/api/server/register_kube.go @@ -0,0 +1,82 @@ +package server + +import ( + "net/http" + + "github.com/containers/podman/v4/pkg/api/handlers/libpod" + "github.com/gorilla/mux" +) + +func (s *APIServer) registerKubeHandlers(r *mux.Router) error { + // swagger:operation POST /libpod/kube/play libpod KubePlayLibpod + // --- + // tags: + // - containers + // - pods + // summary: Play a Kubernetes YAML file. + // description: Create and run pods based on a Kubernetes YAML file (pod or service kind). + // parameters: + // - in: query + // name: network + // type: array + // description: USe the network mode or specify an array of networks. + // items: + // type: string + // - in: query + // name: tlsVerify + // type: boolean + // default: true + // description: Require HTTPS and verify signatures when contacting registries. + // - in: query + // 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: query + // name: staticIPs + // type: array + // description: Static IPs used for the pods. + // items: + // type: string + // - in: query + // name: staticMACs + // type: array + // description: Static MACs used for the pods. + // items: + // type: string + // - in: body + // name: request + // description: Kubernetes YAML file. + // schema: + // type: string + // produces: + // - application/json + // responses: + // 200: + // $ref: "#/responses/kubePlayResponseLibpod" + // 500: + // $ref: "#/responses/internalError" + r.HandleFunc(VersionedPath("/libpod/kube/play"), s.APIHandler(libpod.KubePlay)).Methods(http.MethodPost) + r.HandleFunc(VersionedPath("/libpod/play/kube"), s.APIHandler(libpod.PlayKube)).Methods(http.MethodPost) + // swagger:operation DELETE /libpod/kube/play libpod KubePlayDownLibpod + // --- + // tags: + // - containers + // - pods + // summary: Remove pods from kube play + // description: Tears down pods defined in a YAML file + // produces: + // - application/json + // responses: + // 200: + // $ref: "#/responses/kubePlayResponseLibpod" + // 500: + // $ref: "#/responses/internalError" + r.HandleFunc(VersionedPath("/libpod/kube/play"), s.APIHandler(libpod.KubePlayDown)).Methods(http.MethodDelete) + r.HandleFunc(VersionedPath("/libpod/play/kube"), s.APIHandler(libpod.PlayKubeDown)).Methods(http.MethodDelete) + return nil +} diff --git a/pkg/api/server/register_play.go b/pkg/api/server/register_play.go deleted file mode 100644 index 35da80ccc..000000000 --- a/pkg/api/server/register_play.go +++ /dev/null @@ -1,80 +0,0 @@ -package server - -import ( - "net/http" - - "github.com/containers/podman/v4/pkg/api/handlers/libpod" - "github.com/gorilla/mux" -) - -func (s *APIServer) registerPlayHandlers(r *mux.Router) error { - // swagger:operation POST /libpod/play/kube libpod PlayKubeLibpod - // --- - // tags: - // - containers - // - pods - // summary: Play a Kubernetes YAML file. - // description: Create and run pods based on a Kubernetes YAML file (pod or service kind). - // parameters: - // - in: query - // name: network - // type: array - // description: USe the network mode or specify an array of networks. - // items: - // type: string - // - in: query - // name: tlsVerify - // type: boolean - // default: true - // description: Require HTTPS and verify signatures when contacting registries. - // - in: query - // 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: query - // name: staticIPs - // type: array - // description: Static IPs used for the pods. - // items: - // type: string - // - in: query - // name: staticMACs - // type: array - // description: Static MACs used for the pods. - // items: - // type: string - // - in: body - // name: request - // description: Kubernetes YAML file. - // schema: - // type: string - // produces: - // - application/json - // responses: - // 200: - // $ref: "#/responses/playKubeResponseLibpod" - // 500: - // $ref: "#/responses/internalError" - r.HandleFunc(VersionedPath("/libpod/play/kube"), s.APIHandler(libpod.PlayKube)).Methods(http.MethodPost) - // swagger:operation DELETE /libpod/play/kube libpod PlayKubeDownLibpod - // --- - // tags: - // - containers - // - pods - // summary: Remove pods from play kube - // description: Tears down pods defined in a YAML file - // produces: - // - application/json - // responses: - // 200: - // $ref: "#/responses/playKubeResponseLibpod" - // 500: - // $ref: "#/responses/internalError" - r.HandleFunc(VersionedPath("/libpod/play/kube"), s.APIHandler(libpod.PlayKubeDown)).Methods(http.MethodDelete) - return nil -} diff --git a/pkg/api/server/server.go b/pkg/api/server/server.go index 5482a8ec2..a6d8b5e4c 100644 --- a/pkg/api/server/server.go +++ b/pkg/api/server/server.go @@ -126,11 +126,11 @@ func newServer(runtime *libpod.Runtime, listener net.Listener, opts entities.Ser server.registerHealthCheckHandlers, server.registerImagesHandlers, server.registerInfoHandlers, + server.registerKubeHandlers, server.registerManifestHandlers, server.registerMonitorHandlers, server.registerNetworkHandlers, server.registerPingHandlers, - server.registerPlayHandlers, server.registerPluginsHandlers, server.registerPodsHandlers, server.registerSecretHandlers, -- cgit v1.2.3-54-g00ecf