From 5c21861b5d964c86bc33af30e83cdcb82e198c1b Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 14 Apr 2021 12:02:37 -0400 Subject: Fix flake on failed podman-remote build We have a race condition where podman build can fail but still return an exit code of 0. This PR ensures that as soon as the build fails, the failed flag is set eliminating the race. Fixes: https://github.com/containers/podman/issues/10029 [NO TESTS NEEDED] Tests of failed builds are already in place, and the elimination of the race should be enough. Signed-off-by: Daniel J Walsh --- pkg/api/handlers/compat/images_build.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'pkg') diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 36785a362..b7c5bf2d6 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -376,12 +376,17 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { buildOptions.Timestamp = &ts } + var ( + imageID string + failed bool + ) + runCtx, cancel := context.WithCancel(context.Background()) - var imageID string go func() { defer cancel() imageID, _, err = runtime.Build(r.Context(), buildOptions, query.Dockerfile) if err != nil { + failed = true stderr.Write([]byte(err.Error() + "\n")) } }() @@ -397,8 +402,6 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { w.Header().Add("Content-Type", "application/json") flush() - var failed bool - body := w.(io.Writer) if logrus.IsLevelEnabled(logrus.DebugLevel) { if v, found := os.LookupEnv("PODMAN_RETAIN_BUILD_ARTIFACT"); found { @@ -439,7 +442,6 @@ loop: } flush() case e := <-stderr.Chan(): - failed = true m.Error = string(e) if err := enc.Encode(m); err != nil { logrus.Warnf("Failed to json encode error %v", err) -- cgit v1.2.3-54-g00ecf From fc99c7d0a3c9cfaec0658d552a5e43cda275ba55 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 14 Apr 2021 15:55:09 -0400 Subject: Fix flake on failed podman-remote build : try 2 This time we are checking if the function actually succeeded, otherwise we will report an error. Also if we did not get the id, report unexpected failure. [NO TESTS NEEDED] Still no good way to test this, but manually. Signed-off-by: Daniel J Walsh --- pkg/api/handlers/compat/images_build.go | 10 ++++++---- pkg/bindings/images/build.go | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'pkg') diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index b7c5bf2d6..5b8741e89 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -378,15 +378,16 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { var ( imageID string - failed bool + success bool ) runCtx, cancel := context.WithCancel(context.Background()) go func() { defer cancel() imageID, _, err = runtime.Build(r.Context(), buildOptions, query.Dockerfile) - if err != nil { - failed = true + if err == nil { + success = true + } else { stderr.Write([]byte(err.Error() + "\n")) } }() @@ -448,7 +449,8 @@ loop: } flush() case <-runCtx.Done(): - if !failed { + flush() + if success { if !utils.IsLibpodRequest(r) { m.Stream = fmt.Sprintf("Successfully built %12.12s\n", imageID) if err := enc.Encode(m); err != nil { diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index 17095b84b..06aa838db 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -304,6 +304,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO re := regexp.MustCompile(`[0-9a-f]{12}`) var id string + var mErr error for { var s struct { Stream string `json:"stream,omitempty"` @@ -311,11 +312,21 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO } if err := dec.Decode(&s); err != nil { if errors.Is(err, io.EOF) { - return &entities.BuildReport{ID: id}, nil + if mErr == nil && id == "" { + mErr = errors.New("stream dropped, unexpected failure") + } + break } s.Error = err.Error() + "\n" } + select { + case <-response.Request.Context().Done(): + return &entities.BuildReport{ID: id}, mErr + default: + // non-blocking select + } + switch { case s.Stream != "": stdout.Write([]byte(s.Stream)) @@ -323,11 +334,12 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO id = strings.TrimSuffix(s.Stream, "\n") } case s.Error != "": - return nil, errors.New(s.Error) + mErr = errors.New(s.Error) default: return &entities.BuildReport{ID: id}, errors.New("failed to parse build results stream, unexpected input") } } + return &entities.BuildReport{ID: id}, mErr } func nTar(excludes []string, sources ...string) (io.ReadCloser, error) { -- cgit v1.2.3-54-g00ecf From 4d4babac7615ac832edaa8d405b507e5264a2122 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Mon, 5 Apr 2021 18:12:50 -0400 Subject: Fix handling of $NAME and $IMAGE in runlabel Fixes: https://github.com/containers/podman/issues/9405 Add system runlabel tests. Signed-off-by: Daniel J Walsh --- .../source/markdown/podman-container-runlabel.1.md | 2 +- pkg/domain/infra/abi/containers_runlabel.go | 25 ++++++++--------- test/system/037-runlabel.bats | 32 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 test/system/037-runlabel.bats (limited to 'pkg') diff --git a/docs/source/markdown/podman-container-runlabel.1.md b/docs/source/markdown/podman-container-runlabel.1.md index 84d283cf8..9557303b6 100644 --- a/docs/source/markdown/podman-container-runlabel.1.md +++ b/docs/source/markdown/podman-container-runlabel.1.md @@ -13,7 +13,7 @@ exist, `podman container runlabel` will just exit. If the container image has a LABEL INSTALL instruction like the following: -`LABEL INSTALL /usr/bin/podman run -t -i --rm \${OPT1} --privileged -v /:/host --net=host --ipc=host --pid=host -e HOST=/host -e NAME=\${NAME} -e IMAGE=\${IMAGE} -e CONFDIR=\/etc/${NAME} -e LOGDIR=/var/log/\${NAME} -e DATADIR=/var/lib/\${NAME} \${IMAGE} \${OPT2} /bin/install.sh \${OPT3}` +`LABEL INSTALL /usr/bin/podman run -t -i --rm \${OPT1} --privileged -v /:/host --net=host --ipc=host --pid=host -e HOST=/host -e NAME=\${NAME} -e IMAGE=\${IMAGE} -e CONFDIR=/etc/\${NAME} -e LOGDIR=/var/log/\${NAME} -e DATADIR=/var/lib/\${NAME} \${IMAGE} \${OPT2} /bin/install.sh \${OPT3}` `podman container runlabel` will set the following environment variables for use in the command: diff --git a/pkg/domain/infra/abi/containers_runlabel.go b/pkg/domain/infra/abi/containers_runlabel.go index 8de383926..2cabab988 100644 --- a/pkg/domain/infra/abi/containers_runlabel.go +++ b/pkg/domain/infra/abi/containers_runlabel.go @@ -177,6 +177,16 @@ func generateRunlabelCommand(runlabel string, img *image.Image, args []string, o return cmd, env, nil } +func replaceName(arg, name string) string { + newarg := strings.ReplaceAll(arg, "$NAME", name) + return strings.ReplaceAll(newarg, "${NAME}", name) +} + +func replaceImage(arg, image string) string { + newarg := strings.ReplaceAll(arg, "$IMAGE", image) + return strings.ReplaceAll(newarg, "${IMAGE}", image) +} + // generateCommand takes a label (string) and converts it to an executable command func generateCommand(command, imageName, name, globalOpts string) ([]string, error) { if name == "" { @@ -196,26 +206,15 @@ func generateCommand(command, imageName, name, globalOpts string) ([]string, err for _, arg := range cmd[1:] { var newArg string switch arg { - case "IMAGE": - newArg = imageName - case "$IMAGE": - newArg = imageName case "IMAGE=IMAGE": newArg = fmt.Sprintf("IMAGE=%s", imageName) - case "IMAGE=$IMAGE": - newArg = fmt.Sprintf("IMAGE=%s", imageName) - case "NAME": - newArg = name case "NAME=NAME": newArg = fmt.Sprintf("NAME=%s", name) - case "NAME=$NAME": - newArg = fmt.Sprintf("NAME=%s", name) - case "$NAME": - newArg = name case "$GLOBAL_OPTS": newArg = globalOpts default: - newArg = arg + newArg = replaceName(arg, name) + newArg = replaceImage(newArg, imageName) } newCommand = append(newCommand, newArg) } diff --git a/test/system/037-runlabel.bats b/test/system/037-runlabel.bats new file mode 100644 index 000000000..8e18f40d3 --- /dev/null +++ b/test/system/037-runlabel.bats @@ -0,0 +1,32 @@ +#!/usr/bin/env bats + +load helpers + +@test "podman container runlabel test" { + skip_if_remote "container runlabel is not supported for remote" + tmpdir=$PODMAN_TMPDIR/runlabel-test + mkdir -p $tmpdir + containerfile=$tmpdir/Containerfile + rand1=$(random_string 30) + rand2=$(random_string 30) + rand3=$(random_string 30) + cat >$containerfile < Date: Wed, 14 Apr 2021 13:38:27 -0400 Subject: pkg/errorhandling.JoinErrors: don't throw away context for lone errors When our multierror contains just one error, don't extract its text only to rewrap it, because doing so discards any stack trace information that might have been added closer to where the error actually originated. Signed-off-by: Nalin Dahyabhai --- pkg/errorhandling/errorhandling.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pkg') diff --git a/pkg/errorhandling/errorhandling.go b/pkg/errorhandling/errorhandling.go index b1923be98..9dc545ebb 100644 --- a/pkg/errorhandling/errorhandling.go +++ b/pkg/errorhandling/errorhandling.go @@ -24,6 +24,9 @@ func JoinErrors(errs []error) error { if finalErr == nil { return finalErr } + if len(multiE.WrappedErrors()) == 1 && logrus.IsLevelEnabled(logrus.TraceLevel) { + return multiE.WrappedErrors()[0] + } return errors.New(strings.TrimSpace(finalErr.Error())) } -- cgit v1.2.3-54-g00ecf From 0e28e3da3fb80ae77f3c7a4ba09da0b467914339 Mon Sep 17 00:00:00 2001 From: Jakub Guzik Date: Tue, 13 Apr 2021 09:16:25 +0200 Subject: Reflect current state of prune implementation in docs Signed-off-by: Jakub Guzik --- pkg/api/server/register_networks.go | 1 - pkg/api/server/register_volumes.go | 12 ++++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'pkg') diff --git a/pkg/api/server/register_networks.go b/pkg/api/server/register_networks.go index a07c6a55e..7710fb83f 100644 --- a/pkg/api/server/register_networks.go +++ b/pkg/api/server/register_networks.go @@ -382,7 +382,6 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // name: filters // type: string // description: | - // NOT IMPLEMENTED // Filters to process on the prune list, encoded as JSON (a map[string][]string). // Available filters: // - until= Prune networks created before this timestamp. The can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. 10m, 1h30m) computed relative to the daemon machine’s time. diff --git a/pkg/api/server/register_volumes.go b/pkg/api/server/register_volumes.go index b19faefdd..b03f26487 100644 --- a/pkg/api/server/register_volumes.go +++ b/pkg/api/server/register_volumes.go @@ -81,6 +81,14 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // summary: Prune volumes // produces: // - application/json + // parameters: + // - in: query + // name: filters + // type: string + // description: | + // JSON encoded value of filters (a map[string][]string) to match volumes against before pruning. + // Available filters: + // - label (label=, label==, label!=, or label!==) Prune volumes with (or without, in case label!=... is used) the specified labels. // responses: // '200': // "$ref": "#/responses/VolumePruneResponse" @@ -259,8 +267,8 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // type: string // description: | // JSON encoded value of filters (a map[string][]string) to match volumes against before pruning. - // - // Note: No filters are currently supported and any filters specified will cause an error response. + // Available filters: + // - label (label=, label==, label!=, or label!==) Prune volumes with (or without, in case label!=... is used) the specified labels. // responses: // '200': // "$ref": "#/responses/DockerVolumePruneResponse" -- cgit v1.2.3-54-g00ecf From f218d8849dd27d13a990bf998e64a40169e8674c Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Mon, 12 Apr 2021 09:33:51 -0700 Subject: [CI:DOCS] Correct status code for /pods/create Swagger documentation reported that the API endpoint /pods/create returned 200 while the as-built code returned 201. 201 is more correct so documentation updated. Tests already checked for 201 so no updated needed. Signed-off-by: Jhon Honce --- pkg/api/server/register_pods.go | 2 +- test/apiv2/rest_api/test_rest_v2_0_0.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/api/server/register_pods.go b/pkg/api/server/register_pods.go index c66cc48ff..d0887aada 100644 --- a/pkg/api/server/register_pods.go +++ b/pkg/api/server/register_pods.go @@ -38,7 +38,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // schema: // $ref: "#/definitions/PodSpecGenerator" // responses: - // 200: + // 201: // schema: // $ref: "#/definitions/IdResponse" // 400: diff --git a/test/apiv2/rest_api/test_rest_v2_0_0.py b/test/apiv2/rest_api/test_rest_v2_0_0.py index d7910f555..9924bd65e 100644 --- a/test/apiv2/rest_api/test_rest_v2_0_0.py +++ b/test/apiv2/rest_api/test_rest_v2_0_0.py @@ -728,5 +728,6 @@ class TestApi(unittest.TestCase): self.assertGreater(len(start["Errs"]), 0, r.text) + if __name__ == "__main__": unittest.main() -- cgit v1.2.3-54-g00ecf From a23aecf1a69687f5a75784e3eef1500e8872c3d8 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 9 Apr 2021 10:07:46 +0200 Subject: cgroups: force 64 bits to ParseUint [NO TESTS NEEDED] force bitsSize==64 so that the string is always parsed to a uint64 instead of using the native int size, that could be not big enough on 32 bits arches. Closes: https://github.com/containers/podman/issues/9979 Signed-off-by: Giuseppe Scrivano --- pkg/cgroups/cgroups.go | 2 +- pkg/cgroups/cpu.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'pkg') diff --git a/pkg/cgroups/cgroups.go b/pkg/cgroups/cgroups.go index 608e1647a..aefb5183b 100644 --- a/pkg/cgroups/cgroups.go +++ b/pkg/cgroups/cgroups.go @@ -265,7 +265,7 @@ func readFileAsUint64(path string) (uint64, error) { if v == "max" { return math.MaxUint64, nil } - ret, err := strconv.ParseUint(v, 10, 0) + ret, err := strconv.ParseUint(v, 10, 64) if err != nil { return ret, errors.Wrapf(err, "parse %s from %s", v, path) } diff --git a/pkg/cgroups/cpu.go b/pkg/cgroups/cpu.go index 05223c2e1..23539757d 100644 --- a/pkg/cgroups/cpu.go +++ b/pkg/cgroups/cpu.go @@ -40,7 +40,7 @@ func readAcctList(ctr *CgroupControl, name string) ([]uint64, error) { if s == "" { break } - v, err := strconv.ParseUint(s, 10, 0) + v, err := strconv.ParseUint(s, 10, 64) if err != nil { return nil, errors.Wrapf(err, "parsing %s", s) } @@ -80,14 +80,14 @@ func (c *cpuHandler) Stat(ctr *CgroupControl, m *Metrics) error { return err } if val, found := values["usage_usec"]; found { - usage.Total, err = strconv.ParseUint(cleanString(val[0]), 10, 0) + usage.Total, err = strconv.ParseUint(cleanString(val[0]), 10, 64) if err != nil { return err } usage.Kernel *= 1000 } if val, found := values["system_usec"]; found { - usage.Kernel, err = strconv.ParseUint(cleanString(val[0]), 10, 0) + usage.Kernel, err = strconv.ParseUint(cleanString(val[0]), 10, 64) if err != nil { return err } @@ -149,7 +149,7 @@ func GetSystemCPUUsage() (uint64, error) { } if val, found := values["usage_usec"]; found { - v, err := strconv.ParseUint(cleanString(val[0]), 10, 0) + v, err := strconv.ParseUint(cleanString(val[0]), 10, 64) if err != nil { return 0, err } -- cgit v1.2.3-54-g00ecf From 7ccccd22cd8413e3319c24be6b074385d760d341 Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Wed, 7 Apr 2021 13:55:03 -0700 Subject: Add missing return libpod df handler missing a return after writing error to client. This caused a null to be appended to JSON and crashed python decoder. Signed-off-by: Jhon Honce --- pkg/api/handlers/libpod/system.go | 1 + test/apiv2/rest_api/test_rest_v2_0_0.py | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'pkg') diff --git a/pkg/api/handlers/libpod/system.go b/pkg/api/handlers/libpod/system.go index 02457eb8f..2b4cef1bb 100644 --- a/pkg/api/handlers/libpod/system.go +++ b/pkg/api/handlers/libpod/system.go @@ -72,6 +72,7 @@ func DiskUsage(w http.ResponseWriter, r *http.Request) { response, err := ic.SystemDf(r.Context(), options) if err != nil { utils.InternalServerError(w, err) + return } utils.WriteResponse(w, http.StatusOK, response) } diff --git a/test/apiv2/rest_api/test_rest_v2_0_0.py b/test/apiv2/rest_api/test_rest_v2_0_0.py index 9924bd65e..75e07ad3c 100644 --- a/test/apiv2/rest_api/test_rest_v2_0_0.py +++ b/test/apiv2/rest_api/test_rest_v2_0_0.py @@ -727,6 +727,10 @@ class TestApi(unittest.TestCase): start = json.loads(r.text) self.assertGreater(len(start["Errs"]), 0, r.text) + def test_df(self): + r = requests.get(_url("/system/df")) + self.assertEqual(r.status_code, 200, r.text) + if __name__ == "__main__": -- cgit v1.2.3-54-g00ecf From 850ead493282340920073f09053bd3bf6bf348ed Mon Sep 17 00:00:00 2001 From: Pablo Correa Gómez Date: Wed, 7 Apr 2021 18:56:37 +0200 Subject: Adjust libpod API Container Wait documentation to the code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #9960 Signed-off-by: Pablo Correa Gómez --- pkg/api/server/register_containers.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/api/server/register_containers.go b/pkg/api/server/register_containers.go index b379d52ce..6813b834a 100644 --- a/pkg/api/server/register_containers.go +++ b/pkg/api/server/register_containers.go @@ -1194,11 +1194,22 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - removing // - stopping // description: "Conditions to wait for. If no condition provided the 'exited' condition is assumed." + // - in: query + // name: interval + // type: string + // default: "250ms" + // description: Time Interval to wait before polling for completion. // produces: // - application/json + // - text/plain // responses: // 200: - // $ref: "#/responses/ContainerWaitResponse" + // description: Status code + // schema: + // type: integer + // format: int32 + // examples: + // text/plain: 137 // 404: // $ref: "#/responses/NoSuchContainer" // 500: -- cgit v1.2.3-54-g00ecf From 3338901c4fe0c185a3980b799d2f687d0731b327 Mon Sep 17 00:00:00 2001 From: Jakub Guzik Date: Wed, 7 Apr 2021 00:02:12 +0200 Subject: Volumes prune endpoint should use only prune filters Volumes endpoints for HTTP compat and libpod APIs allowed usage of list HTTP endpoint filter funcs. Documentation in case of compat API does not allow that. This commit aligns code with the documentation and also ligns libpod with compat API. Signed-off-by: Jakub Guzik --- pkg/api/handlers/compat/volumes.go | 2 +- pkg/api/handlers/libpod/volumes.go | 2 +- pkg/domain/filters/volumes.go | 20 +++++++++++++++++++- test/apiv2/30-volumes.at | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) (limited to 'pkg') diff --git a/pkg/api/handlers/compat/volumes.go b/pkg/api/handlers/compat/volumes.go index 42ece643b..d86fc1e19 100644 --- a/pkg/api/handlers/compat/volumes.go +++ b/pkg/api/handlers/compat/volumes.go @@ -266,7 +266,7 @@ func PruneVolumes(w http.ResponseWriter, r *http.Request) { } f := (url.Values)(*filterMap) - filterFuncs, err := filters.GenerateVolumeFilters(f) + filterFuncs, err := filters.GeneratePruneVolumeFilters(f) if err != nil { utils.Error(w, "Something when wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to parse filters for %s", f.Encode())) return diff --git a/pkg/api/handlers/libpod/volumes.go b/pkg/api/handlers/libpod/volumes.go index 442b53d1e..68aec30d5 100644 --- a/pkg/api/handlers/libpod/volumes.go +++ b/pkg/api/handlers/libpod/volumes.go @@ -150,7 +150,7 @@ func pruneVolumesHelper(r *http.Request) ([]*reports.PruneReport, error) { } f := (url.Values)(*filterMap) - filterFuncs, err := filters.GenerateVolumeFilters(f) + filterFuncs, err := filters.GeneratePruneVolumeFilters(f) if err != nil { return nil, err } diff --git a/pkg/domain/filters/volumes.go b/pkg/domain/filters/volumes.go index 9b2fc5280..9a08adf82 100644 --- a/pkg/domain/filters/volumes.go +++ b/pkg/domain/filters/volumes.go @@ -75,7 +75,25 @@ func GenerateVolumeFilters(filters url.Values) ([]libpod.VolumeFilter, error) { return dangling }) default: - return nil, errors.Errorf("%q is in an invalid volume filter", filter) + return nil, errors.Errorf("%q is an invalid volume filter", filter) + } + } + } + return vf, nil +} + +func GeneratePruneVolumeFilters(filters url.Values) ([]libpod.VolumeFilter, error) { + var vf []libpod.VolumeFilter + for filter, v := range filters { + for _, val := range v { + switch filter { + case "label": + filter := val + vf = append(vf, func(v *libpod.Volume) bool { + return util.MatchLabelFilters([]string{filter}, v.Labels()) + }) + default: + return nil, errors.Errorf("%q is an invalid volume filter", filter) } } } diff --git a/test/apiv2/30-volumes.at b/test/apiv2/30-volumes.at index 18ff31100..623e691e3 100644 --- a/test/apiv2/30-volumes.at +++ b/test/apiv2/30-volumes.at @@ -123,4 +123,20 @@ t POST libpod/volumes/prune 200 #After prune volumes, there should be no volume existing t GET libpod/volumes/json 200 length=0 +# libpod api: do not use list filters for prune +t POST libpod/volumes/prune?filters='{"name":["anyname"]}' 500 \ + .cause="\"name\" is an invalid volume filter" +t POST libpod/volumes/prune?filters='{"driver":["anydriver"]}' 500 \ + .cause="\"driver\" is an invalid volume filter" +t POST libpod/volumes/prune?filters='{"scope":["anyscope"]}' 500 \ + .cause="\"scope\" is an invalid volume filter" + +# compat api: do not use list filters for prune +t POST volumes/prune?filters='{"name":["anyname"]}' 500 \ + .cause="\"name\" is an invalid volume filter" +t POST volumes/prune?filters='{"driver":["anydriver"]}' 500 \ + .cause="\"driver\" is an invalid volume filter" +t POST volumes/prune?filters='{"scope":["anyscope"]}' 500 \ + .cause="\"scope\" is an invalid volume filter" + # vim: filetype=sh -- cgit v1.2.3-54-g00ecf From 1df7f8e969556bd650d9daad2e4dfe0895ec433f Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Wed, 7 Apr 2021 09:18:23 -0700 Subject: [CI:DOCS] Update swagger definition of inspect manifest * Changed reference in swagger to correct struture that was being returned. * Added summary to ManifestAddLibpod to clean up generated web site * Added serve target to Makefile, to aid in debugging generated web site Signed-off-by: Jhon Honce --- pkg/api/Makefile | 3 +++ pkg/api/handlers/libpod/swagger.go | 2 +- pkg/api/server/register_manifest.go | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/api/Makefile b/pkg/api/Makefile index 6b24bfd83..6da5fb57e 100644 --- a/pkg/api/Makefile +++ b/pkg/api/Makefile @@ -5,6 +5,9 @@ SWAGGER_OUT ?= swagger.yaml validate: ${SWAGGER_OUT} swagger validate ${SWAGGER_OUT} +serve: ${SWAGGER_OUT} + swagger serve -F redoc -p=8080 swagger.yaml + .PHONY: ${SWAGGER_OUT} ${SWAGGER_OUT}: # generate doesn't remove file on error diff --git a/pkg/api/handlers/libpod/swagger.go b/pkg/api/handlers/libpod/swagger.go index 2631f19ac..9450a70d9 100644 --- a/pkg/api/handlers/libpod/swagger.go +++ b/pkg/api/handlers/libpod/swagger.go @@ -25,7 +25,7 @@ type swagInspectPodResponse struct { // swagger:response InspectManifest type swagInspectManifestResponse struct { // in:body - Body manifest.List + Body manifest.Schema2List } // Kill Pod diff --git a/pkg/api/server/register_manifest.go b/pkg/api/server/register_manifest.go index c2da5156b..adb545b51 100644 --- a/pkg/api/server/register_manifest.go +++ b/pkg/api/server/register_manifest.go @@ -81,6 +81,7 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { r.Handle(VersionedPath("/libpod/manifests/{name:.*}/json"), s.APIHandler(libpod.ManifestInspect)).Methods(http.MethodGet) // swagger:operation POST /libpod/manifests/{name:.*}/add manifests AddManifest // --- + // summary: Add image // description: Add an image to a manifest list // produces: // - application/json -- cgit v1.2.3-54-g00ecf From 0cbd3225909d982a7dbd5fbc8c593dc1315abb8b Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 5 Apr 2021 15:49:35 -0400 Subject: Ensure that `--userns=keep-id` sets user in config One of the side-effects of the `--userns=keep-id` command is switching the default user of the container to the UID of the user running Podman (though this can still be overridden by the `--user` flag). However, it did this by setting the UID and GID in the OCI spec, and not by informing Libpod of its intention to switch users via the `WithUser()` option. Because of this, a lot of the code that should have triggered when the container ran with a non-root user was not triggering. In the case of the issue that this fixed, the code to remove capabilities from non-root users was not triggering. Adjust the keep-id code to properly inform Libpod of our intention to use a non-root user to fix this. Also, fix an annoying race around short-running exec sessions where Podman would always print a warning that the exec session had already stopped. Fixes #9919 Signed-off-by: Matthew Heon --- libpod/container_exec.go | 27 +++++++- libpod/container_validate.go | 6 ++ libpod/oci_conmon_exec_linux.go | 124 +++++++++++++++++++++++++++++++++++++ libpod/oci_conmon_linux.go | 120 ----------------------------------- pkg/specgen/generate/namespaces.go | 10 +++ test/e2e/exec_test.go | 14 ++++- 6 files changed, 178 insertions(+), 123 deletions(-) (limited to 'pkg') diff --git a/libpod/container_exec.go b/libpod/container_exec.go index bb43287d9..8d8ed14aa 100644 --- a/libpod/container_exec.go +++ b/libpod/container_exec.go @@ -696,6 +696,24 @@ func (c *Container) ExecResize(sessionID string, newSize define.TerminalSize) er return errors.Wrapf(define.ErrExecSessionStateInvalid, "cannot resize container %s exec session %s as it is not running", c.ID(), session.ID()) } + // The exec session may have exited since we last updated. + // Needed to prevent race conditions around short-running exec sessions. + running, err := c.ociRuntime.ExecUpdateStatus(c, session.ID()) + if err != nil { + return err + } + if !running { + session.State = define.ExecStateStopped + + if err := c.save(); err != nil { + logrus.Errorf("Error saving state of container %s: %v", c.ID(), err) + } + + return errors.Wrapf(define.ErrExecSessionStateInvalid, "cannot resize container %s exec session %s as it has stopped", c.ID(), session.ID()) + } + + // Make sure the exec session is still running. + return c.ociRuntime.ExecAttachResize(c, sessionID, newSize) } @@ -720,8 +738,13 @@ func (c *Container) Exec(config *ExecConfig, streams *define.AttachStreams, resi logrus.Debugf("Sending resize events to exec session %s", sessionID) for resizeRequest := range resize { if err := c.ExecResize(sessionID, resizeRequest); err != nil { - // Assume the exec session went down. - logrus.Warnf("Error resizing exec session %s: %v", sessionID, err) + if errors.Cause(err) == define.ErrExecSessionStateInvalid { + // The exec session stopped + // before we could resize. + logrus.Infof("Missed resize on exec session %s, already stopped", sessionID) + } else { + logrus.Warnf("Error resizing exec session %s: %v", sessionID, err) + } return } } diff --git a/libpod/container_validate.go b/libpod/container_validate.go index 245121a91..aae96ae85 100644 --- a/libpod/container_validate.go +++ b/libpod/container_validate.go @@ -126,5 +126,11 @@ func (c *Container) validate() error { } } + // If User in the OCI spec is set, require that c.config.User is set for + // security reasons (a lot of our code relies on c.config.User). + if c.config.User == "" && (c.config.Spec.Process.User.UID != 0 || c.config.Spec.Process.User.GID != 0) { + return errors.Wrapf(define.ErrInvalidArg, "please set User explicitly via WithUser() instead of in OCI spec directly") + } + return nil } diff --git a/libpod/oci_conmon_exec_linux.go b/libpod/oci_conmon_exec_linux.go index 173edba2b..b43316951 100644 --- a/libpod/oci_conmon_exec_linux.go +++ b/libpod/oci_conmon_exec_linux.go @@ -2,18 +2,23 @@ package libpod import ( "fmt" + "io/ioutil" "net/http" "os" "os/exec" "path/filepath" + "strings" "syscall" "time" + "github.com/containers/common/pkg/capabilities" "github.com/containers/common/pkg/config" "github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/pkg/errorhandling" + "github.com/containers/podman/v3/pkg/lookup" "github.com/containers/podman/v3/pkg/util" "github.com/containers/podman/v3/utils" + spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/sys/unix" @@ -654,3 +659,122 @@ func attachExecHTTP(c *Container, sessionID string, r *http.Request, w http.Resp } } } + +// prepareProcessExec returns the path of the process.json used in runc exec -p +// caller is responsible to close the returned *os.File if needed. +func prepareProcessExec(c *Container, options *ExecOptions, env []string, sessionID string) (*os.File, error) { + f, err := ioutil.TempFile(c.execBundlePath(sessionID), "exec-process-") + if err != nil { + return nil, err + } + pspec := new(spec.Process) + if err := JSONDeepCopy(c.config.Spec.Process, pspec); err != nil { + return nil, err + } + pspec.SelinuxLabel = c.config.ProcessLabel + pspec.Args = options.Cmd + + // We need to default this to false else it will inherit terminal as true + // from the container. + pspec.Terminal = false + if options.Terminal { + pspec.Terminal = true + } + if len(env) > 0 { + pspec.Env = append(pspec.Env, env...) + } + + if options.Cwd != "" { + pspec.Cwd = options.Cwd + } + + var addGroups []string + var sgids []uint32 + + // if the user is empty, we should inherit the user that the container is currently running with + user := options.User + if user == "" { + logrus.Debugf("Set user to %s", c.config.User) + user = c.config.User + addGroups = c.config.Groups + } + + overrides := c.getUserOverrides() + execUser, err := lookup.GetUserGroupInfo(c.state.Mountpoint, user, overrides) + if err != nil { + return nil, err + } + + if len(addGroups) > 0 { + sgids, err = lookup.GetContainerGroups(addGroups, c.state.Mountpoint, overrides) + if err != nil { + return nil, errors.Wrapf(err, "error looking up supplemental groups for container %s exec session %s", c.ID(), sessionID) + } + } + + // If user was set, look it up in the container to get a UID to use on + // the host + if user != "" || len(sgids) > 0 { + if user != "" { + for _, sgid := range execUser.Sgids { + sgids = append(sgids, uint32(sgid)) + } + } + processUser := spec.User{ + UID: uint32(execUser.Uid), + GID: uint32(execUser.Gid), + AdditionalGids: sgids, + } + + pspec.User = processUser + } + + ctrSpec, err := c.specFromState() + if err != nil { + return nil, err + } + + allCaps, err := capabilities.BoundingSet() + if err != nil { + return nil, err + } + if options.Privileged { + pspec.Capabilities.Bounding = allCaps + } else { + pspec.Capabilities.Bounding = ctrSpec.Process.Capabilities.Bounding + } + if execUser.Uid == 0 { + pspec.Capabilities.Effective = pspec.Capabilities.Bounding + pspec.Capabilities.Inheritable = pspec.Capabilities.Bounding + pspec.Capabilities.Permitted = pspec.Capabilities.Bounding + pspec.Capabilities.Ambient = pspec.Capabilities.Bounding + } else { + if user == c.config.User { + pspec.Capabilities.Effective = ctrSpec.Process.Capabilities.Effective + pspec.Capabilities.Inheritable = ctrSpec.Process.Capabilities.Effective + pspec.Capabilities.Permitted = ctrSpec.Process.Capabilities.Effective + pspec.Capabilities.Ambient = ctrSpec.Process.Capabilities.Effective + } + } + + hasHomeSet := false + for _, s := range pspec.Env { + if strings.HasPrefix(s, "HOME=") { + hasHomeSet = true + break + } + } + if !hasHomeSet { + pspec.Env = append(pspec.Env, fmt.Sprintf("HOME=%s", execUser.Home)) + } + + processJSON, err := json.Marshal(pspec) + if err != nil { + return nil, err + } + + if err := ioutil.WriteFile(f.Name(), processJSON, 0644); err != nil { + return nil, err + } + return f, nil +} diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go index 643a626fc..5e8ed12e7 100644 --- a/libpod/oci_conmon_linux.go +++ b/libpod/oci_conmon_linux.go @@ -22,7 +22,6 @@ import ( "text/template" "time" - "github.com/containers/common/pkg/capabilities" "github.com/containers/common/pkg/config" conmonConfig "github.com/containers/conmon/runner/config" "github.com/containers/podman/v3/libpod/define" @@ -30,7 +29,6 @@ import ( "github.com/containers/podman/v3/pkg/cgroups" "github.com/containers/podman/v3/pkg/checkpoint/crutils" "github.com/containers/podman/v3/pkg/errorhandling" - "github.com/containers/podman/v3/pkg/lookup" "github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/util" "github.com/containers/podman/v3/utils" @@ -1195,124 +1193,6 @@ func (r *ConmonOCIRuntime) createOCIContainer(ctr *Container, restoreOptions *Co return nil } -// prepareProcessExec returns the path of the process.json used in runc exec -p -// caller is responsible to close the returned *os.File if needed. -func prepareProcessExec(c *Container, options *ExecOptions, env []string, sessionID string) (*os.File, error) { - f, err := ioutil.TempFile(c.execBundlePath(sessionID), "exec-process-") - if err != nil { - return nil, err - } - pspec := new(spec.Process) - if err := JSONDeepCopy(c.config.Spec.Process, pspec); err != nil { - return nil, err - } - pspec.SelinuxLabel = c.config.ProcessLabel - pspec.Args = options.Cmd - - // We need to default this to false else it will inherit terminal as true - // from the container. - pspec.Terminal = false - if options.Terminal { - pspec.Terminal = true - } - if len(env) > 0 { - pspec.Env = append(pspec.Env, env...) - } - - if options.Cwd != "" { - pspec.Cwd = options.Cwd - } - - var addGroups []string - var sgids []uint32 - - // if the user is empty, we should inherit the user that the container is currently running with - user := options.User - if user == "" { - user = c.config.User - addGroups = c.config.Groups - } - - overrides := c.getUserOverrides() - execUser, err := lookup.GetUserGroupInfo(c.state.Mountpoint, user, overrides) - if err != nil { - return nil, err - } - - if len(addGroups) > 0 { - sgids, err = lookup.GetContainerGroups(addGroups, c.state.Mountpoint, overrides) - if err != nil { - return nil, errors.Wrapf(err, "error looking up supplemental groups for container %s exec session %s", c.ID(), sessionID) - } - } - - // If user was set, look it up in the container to get a UID to use on - // the host - if user != "" || len(sgids) > 0 { - if user != "" { - for _, sgid := range execUser.Sgids { - sgids = append(sgids, uint32(sgid)) - } - } - processUser := spec.User{ - UID: uint32(execUser.Uid), - GID: uint32(execUser.Gid), - AdditionalGids: sgids, - } - - pspec.User = processUser - } - - ctrSpec, err := c.specFromState() - if err != nil { - return nil, err - } - - allCaps, err := capabilities.BoundingSet() - if err != nil { - return nil, err - } - if options.Privileged { - pspec.Capabilities.Bounding = allCaps - } else { - pspec.Capabilities.Bounding = ctrSpec.Process.Capabilities.Bounding - } - if execUser.Uid == 0 { - pspec.Capabilities.Effective = pspec.Capabilities.Bounding - pspec.Capabilities.Inheritable = pspec.Capabilities.Bounding - pspec.Capabilities.Permitted = pspec.Capabilities.Bounding - pspec.Capabilities.Ambient = pspec.Capabilities.Bounding - } else { - if user == c.config.User { - pspec.Capabilities.Effective = ctrSpec.Process.Capabilities.Effective - pspec.Capabilities.Inheritable = ctrSpec.Process.Capabilities.Effective - pspec.Capabilities.Permitted = ctrSpec.Process.Capabilities.Effective - pspec.Capabilities.Ambient = ctrSpec.Process.Capabilities.Effective - } - } - - hasHomeSet := false - for _, s := range pspec.Env { - if strings.HasPrefix(s, "HOME=") { - hasHomeSet = true - break - } - } - if !hasHomeSet { - pspec.Env = append(pspec.Env, fmt.Sprintf("HOME=%s", execUser.Home)) - } - - processJSON, err := json.Marshal(pspec) - if err != nil { - return nil, err - } - - if err := ioutil.WriteFile(f.Name(), processJSON, 0644); err != nil { - return nil, err - } - return f, nil -} - // configureConmonEnv gets the environment values to add to conmon's exec struct // TODO this may want to be less hardcoded/more configurable in the future func (r *ConmonOCIRuntime) configureConmonEnv(ctr *Container, runtimeDir string) ([]string, []*os.File) { diff --git a/pkg/specgen/generate/namespaces.go b/pkg/specgen/generate/namespaces.go index b87375a92..214f6c1bc 100644 --- a/pkg/specgen/generate/namespaces.go +++ b/pkg/specgen/generate/namespaces.go @@ -157,6 +157,16 @@ func namespaceOptions(ctx context.Context, s *specgen.SpecGenerator, rt *libpod. case specgen.KeepID: if rootless.IsRootless() { toReturn = append(toReturn, libpod.WithAddCurrentUserPasswdEntry()) + + // If user is not overridden, set user in the container + // to user running Podman. + if s.User == "" { + _, uid, gid, err := util.GetKeepIDMapping() + if err != nil { + return nil, err + } + toReturn = append(toReturn, libpod.WithUser(fmt.Sprintf("%d:%d", uid, gid))) + } } else { // keep-id as root doesn't need a user namespace s.UserNS.NSMode = specgen.Host diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index df86eab15..e6f63a391 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -119,6 +119,19 @@ var _ = Describe("Podman exec", func() { Expect(session.ExitCode()).To(Equal(100)) }) + It("podman exec in keep-id container drops privileges", func() { + SkipIfNotRootless("This function is not enabled for rootful podman") + ctrName := "testctr1" + testCtr := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, "--userns=keep-id", ALPINE, "top"}) + testCtr.WaitWithDefaultTimeout() + Expect(testCtr.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"exec", ctrName, "grep", "CapEff", "/proc/self/status"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("0000000000000000")) + }) + It("podman exec --privileged", func() { session := podmanTest.Podman([]string{"run", "--privileged", "--rm", ALPINE, "sh", "-c", "grep ^CapBnd /proc/self/status | cut -f 2"}) session.WaitWithDefaultTimeout() @@ -143,7 +156,6 @@ var _ = Describe("Podman exec", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) Expect(session.OutputToString()).To(ContainSubstring(bndPerms)) - }) It("podman exec --privileged", func() { -- cgit v1.2.3-54-g00ecf From b3ef9e4dd8f91326b1f5e85360679ec5ffd213f9 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 31 Mar 2021 16:45:35 -0400 Subject: Allow users to override default storage opts with --storage-opt We define in the man page that this overrides the default storage options, but the code was appending to the existing options. This PR also makes a change to allow users to specify --storage-opt="". This will turn off all storage options. https://github.com/containers/podman/issues/9852 Signed-off-by: Daniel J Walsh --- docs/source/markdown/podman.1.md | 2 +- libpod/options.go | 3 +-- pkg/domain/infra/runtime_libpod.go | 6 +++++- test/system/005-info.bats | 9 +++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) (limited to 'pkg') diff --git a/docs/source/markdown/podman.1.md b/docs/source/markdown/podman.1.md index 87e3c4eab..c25ff17fa 100644 --- a/docs/source/markdown/podman.1.md +++ b/docs/source/markdown/podman.1.md @@ -148,7 +148,7 @@ specify additional options via the `--storage-opt` flag. #### **\-\-storage-opt**=*value* -Storage driver option, Default storage driver options are configured in /etc/containers/storage.conf (`$HOME/.config/containers/storage.conf` in rootless mode). The `STORAGE_OPTS` environment variable overrides the default. The --storage-opt specified options overrides all. +Storage driver option, Default storage driver options are configured in /etc/containers/storage.conf (`$HOME/.config/containers/storage.conf` in rootless mode). The `STORAGE_OPTS` environment variable overrides the default. The --storage-opt specified options overrides all. If you specify --storage-opt="", no storage options will be used. #### **\-\-syslog**=*true|false* diff --git a/libpod/options.go b/libpod/options.go index 24e9d74f4..333a7c4a5 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -77,8 +77,7 @@ func WithStorageConfig(config storage.StoreOptions) RuntimeOption { rt.storageConfig.GraphDriverOptions = make([]string, len(config.GraphDriverOptions)) copy(rt.storageConfig.GraphDriverOptions, config.GraphDriverOptions) } else { - // append new options after what is specified in the config files - rt.storageConfig.GraphDriverOptions = append(rt.storageConfig.GraphDriverOptions, config.GraphDriverOptions...) + rt.storageConfig.GraphDriverOptions = config.GraphDriverOptions } setField = true } diff --git a/pkg/domain/infra/runtime_libpod.go b/pkg/domain/infra/runtime_libpod.go index 8b6581c7b..889a81acc 100644 --- a/pkg/domain/infra/runtime_libpod.go +++ b/pkg/domain/infra/runtime_libpod.go @@ -146,7 +146,11 @@ func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpo // This should always be checked after storage-driver is checked if len(cfg.StorageOpts) > 0 { storageSet = true - storageOpts.GraphDriverOptions = cfg.StorageOpts + if len(cfg.StorageOpts) == 1 && cfg.StorageOpts[0] == "" { + storageOpts.GraphDriverOptions = []string{} + } else { + storageOpts.GraphDriverOptions = cfg.StorageOpts + } } if opts.migrate { options = append(options, libpod.WithMigrate()) diff --git a/test/system/005-info.bats b/test/system/005-info.bats index 7452c1901..c0af2e937 100644 --- a/test/system/005-info.bats +++ b/test/system/005-info.bats @@ -53,4 +53,13 @@ store.imageStore.number | 1 } +@test "podman info --storage-opt='' " { + skip_if_remote "--storage-opt flag is not supported for remote" + skip_if_rootless "storage opts are required for rootless running" + run_podman --storage-opt='' info + # Note this will not work in rootless mode, unless you specify + # storage-driver=vfs, until we have kernels that support rootless overlay + # mounts. + is "$output" ".*graphOptions: {}" "output includes graphOptions: {}" +} # vim: filetype=sh -- cgit v1.2.3-54-g00ecf From ea0e530050988e76b63861b14536fb0f638ae496 Mon Sep 17 00:00:00 2001 From: Kellen Dunham Date: Tue, 30 Mar 2021 18:16:03 -0500 Subject: Fixed podman-remote --network flag Updated reference to network [NO TESTS NEEDED] Signed-off-by: Kellen Dunham --- pkg/api/handlers/libpod/play.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/api/handlers/libpod/play.go b/pkg/api/handlers/libpod/play.go index ee2d3c00d..eba5386b6 100644 --- a/pkg/api/handlers/libpod/play.go +++ b/pkg/api/handlers/libpod/play.go @@ -20,7 +20,7 @@ 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:"reference"` + Network string `schema:"network"` TLSVerify bool `schema:"tlsVerify"` LogDriver string `schema:"logDriver"` Start bool `schema:"start"` -- cgit v1.2.3-54-g00ecf From 10bc6233bb621bdc4971ae1da234208b1936d4cc Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 31 Mar 2021 07:37:36 -0400 Subject: Fix handling of remove --log-rusage param Fixes: https://github.com/containers/podman/issues/9889 Signed-off-by: Daniel J Walsh --- pkg/api/handlers/compat/images_build.go | 1 + test/e2e/build_test.go | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'pkg') diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 5b8741e89..52012cde8 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -350,6 +350,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { Jobs: &jobs, Labels: labels, Layers: query.Layers, + LogRusage: query.LogRusage, Manifest: query.Manifest, MaxPullPushRetries: 3, NamespaceOptions: nsoptions, diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index 95ed23313..4f337116e 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -549,4 +549,21 @@ RUN echo hello`, ALPINE) inspect.WaitWithDefaultTimeout() Expect(inspect.OutputToString()).To(Equal("1970-01-01 00:00:00 +0000 UTC")) }) + + It("podman build --log-rusage", func() { + targetPath, err := CreateTempDirInTempDir() + Expect(err).To(BeNil()) + + containerFile := filepath.Join(targetPath, "Containerfile") + content := `FROM scratch` + + Expect(ioutil.WriteFile(containerFile, []byte(content), 0755)).To(BeNil()) + + session := podmanTest.Podman([]string{"build", "--log-rusage", "--pull-never", targetPath}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("(system)")) + Expect(session.OutputToString()).To(ContainSubstring("(user)")) + Expect(session.OutputToString()).To(ContainSubstring("(elapsed)")) + }) }) -- cgit v1.2.3-54-g00ecf From 10a58c976bf716e8f91b80759d3043f5986f5c9e Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Tue, 30 Mar 2021 10:42:06 -0700 Subject: Trim white space from /top endpoint results Versions of the ps command have additional spaces between fields, this manifests as the container asking to run "top" and API reporting "top " as a process. Endpoint and tests updated to check that "top" is reported. There is no libpod specialized endpoint to update. Signed-off-by: Jhon Honce --- pkg/api/handlers/compat/containers_top.go | 10 +++++++++- test/apiv2/25-containersMore.at | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'pkg') diff --git a/pkg/api/handlers/compat/containers_top.go b/pkg/api/handlers/compat/containers_top.go index ab9f613af..cae044a89 100644 --- a/pkg/api/handlers/compat/containers_top.go +++ b/pkg/api/handlers/compat/containers_top.go @@ -46,8 +46,16 @@ func TopContainer(w http.ResponseWriter, r *http.Request) { var body = handlers.ContainerTopOKBody{} if len(output) > 0 { body.Titles = strings.Split(output[0], "\t") + for i := range body.Titles { + body.Titles[i] = strings.TrimSpace(body.Titles[i]) + } + for _, line := range output[1:] { - body.Processes = append(body.Processes, strings.Split(line, "\t")) + process := strings.Split(line, "\t") + for i := range process { + process[i] = strings.TrimSpace(process[i]) + } + body.Processes = append(body.Processes, process) } } utils.WriteJSON(w, http.StatusOK, body) diff --git a/test/apiv2/25-containersMore.at b/test/apiv2/25-containersMore.at index 39bfa2e32..0a049d869 100644 --- a/test/apiv2/25-containersMore.at +++ b/test/apiv2/25-containersMore.at @@ -38,7 +38,8 @@ t GET libpod/containers/foo/json 200 \ # List processes of the container t GET libpod/containers/foo/top 200 \ - length=2 + length=2 \ + .Processes[0][7]="top" # List processes of none such t GET libpod/containers/nonesuch/top 404 -- cgit v1.2.3-54-g00ecf From f5a25c59e3928233da84989da2cbeff73e97c02d Mon Sep 17 00:00:00 2001 From: Jakub Guzik Date: Tue, 30 Mar 2021 10:19:22 +0200 Subject: Containers prune endpoint should use only prune filters Containers endpoints for HTTP compad and libpod APIs allowed usage of list HTTP endpoint filter funcs. Documentation in case of libpod and compat API does not allow that. This commit aligns code with the documentation. Signed-off-by: Jakub Guzik --- pkg/api/handlers/compat/containers_prune.go | 2 +- pkg/bindings/test/containers_test.go | 15 ++++++++---- pkg/domain/filters/containers.go | 37 +++++++++++++++++++++-------- pkg/domain/infra/abi/containers.go | 2 +- test/apiv2/20-containers.at | 18 +++++++++++++- 5 files changed, 57 insertions(+), 17 deletions(-) (limited to 'pkg') diff --git a/pkg/api/handlers/compat/containers_prune.go b/pkg/api/handlers/compat/containers_prune.go index e37929d27..61ea7a89e 100644 --- a/pkg/api/handlers/compat/containers_prune.go +++ b/pkg/api/handlers/compat/containers_prune.go @@ -23,7 +23,7 @@ func PruneContainers(w http.ResponseWriter, r *http.Request) { filterFuncs := make([]libpod.ContainerFilter, 0, len(*filtersMap)) for k, v := range *filtersMap { - generatedFunc, err := filters.GenerateContainerFilterFuncs(k, v, runtime) + generatedFunc, err := filters.GeneratePruneContainerFilterFuncs(k, v, runtime) if err != nil { utils.InternalServerError(w, err) return diff --git a/pkg/bindings/test/containers_test.go b/pkg/bindings/test/containers_test.go index b0ddc7862..cb9e0721b 100644 --- a/pkg/bindings/test/containers_test.go +++ b/pkg/bindings/test/containers_test.go @@ -550,21 +550,28 @@ var _ = Describe("Podman containers ", func() { filtersIncorrect := map[string][]string{ "status": {"dummy"}, } - pruneResponse, err := containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect)) + _, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect)) + Expect(err).ToNot(BeNil()) + + // List filter params should not work with prune. + filtersIncorrect = map[string][]string{ + "name": {"top"}, + } + _, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect)) Expect(err).ToNot(BeNil()) // Mismatched filter params no container should be pruned. filtersIncorrect = map[string][]string{ - "name": {"r"}, + "label": {"xyz"}, } - pruneResponse, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect)) + pruneResponse, err := containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect)) Expect(err).To(BeNil()) Expect(len(reports.PruneReportsIds(pruneResponse))).To(Equal(0)) Expect(len(reports.PruneReportsErrs(pruneResponse))).To(Equal(0)) // Valid filter params container should be pruned now. filters := map[string][]string{ - "name": {"top"}, + "until": {"0s"}, } pruneResponse, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filters)) Expect(err).To(BeNil()) diff --git a/pkg/domain/filters/containers.go b/pkg/domain/filters/containers.go index 84cf03764..19d704da1 100644 --- a/pkg/domain/filters/containers.go +++ b/pkg/domain/filters/containers.go @@ -165,16 +165,7 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo return false }, nil case "until": - until, err := util.ComputeUntilTimestamp(filterValues) - if err != nil { - return nil, err - } - return func(c *libpod.Container) bool { - if !until.IsZero() && c.CreatedTime().After((until)) { - return true - } - return false - }, nil + return prepareUntilFilterFunc(filterValues) case "pod": var pods []*libpod.Pod for _, podNameOrID := range filterValues { @@ -226,3 +217,29 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo } return nil, errors.Errorf("%s is an invalid filter", filter) } + +// GeneratePruneContainerFilterFuncs return ContainerFilter functions based of filter for prune operation +func GeneratePruneContainerFilterFuncs(filter string, filterValues []string, r *libpod.Runtime) (func(container *libpod.Container) bool, error) { + switch filter { + case "label": + return func(c *libpod.Container) bool { + return util.MatchLabelFilters(filterValues, c.Labels()) + }, nil + case "until": + return prepareUntilFilterFunc(filterValues) + } + return nil, errors.Errorf("%s is an invalid filter", filter) +} + +func prepareUntilFilterFunc(filterValues []string) (func(container *libpod.Container) bool, error) { + until, err := util.ComputeUntilTimestamp(filterValues) + if err != nil { + return nil, err + } + return func(c *libpod.Container) bool { + if !until.IsZero() && c.CreatedTime().After((until)) { + return true + } + return false + }, nil +} diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index 637531ee9..24261e5ed 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -194,7 +194,7 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin func (ic *ContainerEngine) ContainerPrune(ctx context.Context, options entities.ContainerPruneOptions) ([]*reports.PruneReport, error) { filterFuncs := make([]libpod.ContainerFilter, 0, len(options.Filters)) for k, v := range options.Filters { - generatedFunc, err := dfilters.GenerateContainerFilterFuncs(k, v, ic.Libpod) + generatedFunc, err := dfilters.GeneratePruneContainerFilterFuncs(k, v, ic.Libpod) if err != nil { return nil, err } diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at index 9030f0095..58b2dff0a 100644 --- a/test/apiv2/20-containers.at +++ b/test/apiv2/20-containers.at @@ -298,7 +298,7 @@ t POST containers/prune?filters='garb1age}' 500 \ t POST libpod/containers/prune?filters='garb1age}' 500 \ .cause="invalid character 'g' looking for beginning of value" -## Prune containers with illformed label +# Prune containers with illformed label t POST containers/prune?filters='{"label":["tes' 500 \ .cause="unexpected end of JSON input" t POST libpod/containers/prune?filters='{"label":["tes' 500 \ @@ -306,6 +306,22 @@ t POST libpod/containers/prune?filters='{"label":["tes' 500 \ t GET libpod/containers/json?filters='{"label":["testlabel"]}' 200 length=0 +# libpod api: do not use list filters for prune +t POST libpod/containers/prune?filters='{"name":["anyname"]}' 500 \ + .cause="name is an invalid filter" +t POST libpod/containers/prune?filters='{"id":["anyid"]}' 500 \ + .cause="id is an invalid filter" +t POST libpod/containers/prune?filters='{"network":["anynetwork"]}' 500 \ + .cause="network is an invalid filter" + +# compat api: do not use list filters for prune +t POST containers/prune?filters='{"name":["anyname"]}' 500 \ + .cause="name is an invalid filter" +t POST containers/prune?filters='{"id":["anyid"]}' 500 \ + .cause="id is an invalid filter" +t POST containers/prune?filters='{"network":["anynetwork"]}' 500 \ + .cause="network is an invalid filter" + # Test CPU limit (NanoCPUs) t POST containers/create Image=$IMAGE HostConfig='{"NanoCpus":500000}' 201 \ .Id~[0-9a-f]\\{64\\} -- cgit v1.2.3-54-g00ecf From b76cc706ad8b8991f741fc12704f535a79769a7b Mon Sep 17 00:00:00 2001 From: Jakub Guzik Date: Thu, 1 Apr 2021 12:10:31 +0200 Subject: Recreate until container prune tests for bindings Signed-off-by: Jakub Guzik Signed-off-by: Matthew Heon --- pkg/bindings/test/containers_test.go | 22 +++++++++++++++++++++- pkg/domain/filters/containers.go | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'pkg') diff --git a/pkg/bindings/test/containers_test.go b/pkg/bindings/test/containers_test.go index cb9e0721b..4d1361746 100644 --- a/pkg/bindings/test/containers_test.go +++ b/pkg/bindings/test/containers_test.go @@ -571,7 +571,7 @@ var _ = Describe("Podman containers ", func() { // Valid filter params container should be pruned now. filters := map[string][]string{ - "until": {"0s"}, + "until": {"5000000000"}, //Friday, June 11, 2128 } pruneResponse, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filters)) Expect(err).To(BeNil()) @@ -579,6 +579,26 @@ var _ = Describe("Podman containers ", func() { Expect(len(reports.PruneReportsIds(pruneResponse))).To(Equal(1)) }) + It("podman list containers with until filter", func() { + var name = "top" + _, err := bt.RunTopContainer(&name, nil) + Expect(err).To(BeNil()) + + filters := map[string][]string{ + "until": {"5000000000"}, //Friday, June 11, 2128 + } + c, err := containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true)) + Expect(err).To(BeNil()) + Expect(len(c)).To(Equal(1)) + + filters = map[string][]string{ + "until": {"500000"}, // Tuesday, January 6, 1970 + } + c, err = containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true)) + Expect(err).To(BeNil()) + Expect(len(c)).To(Equal(0)) + }) + It("podman prune running containers", func() { // Start the container. var name = "top" diff --git a/pkg/domain/filters/containers.go b/pkg/domain/filters/containers.go index 19d704da1..45791cd84 100644 --- a/pkg/domain/filters/containers.go +++ b/pkg/domain/filters/containers.go @@ -237,7 +237,7 @@ func prepareUntilFilterFunc(filterValues []string) (func(container *libpod.Conta return nil, err } return func(c *libpod.Container) bool { - if !until.IsZero() && c.CreatedTime().After((until)) { + if !until.IsZero() && c.CreatedTime().Before(until) { return true } return false -- cgit v1.2.3-54-g00ecf From c042b4c82014c7a3841969c3bfab70203e7cecd6 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 29 Mar 2021 11:44:41 +0200 Subject: rootless: use is_fd_inherited since we already have an exported function that does the check, refactor the code to use it instead of duplicating the logic. Signed-off-by: Giuseppe Scrivano --- pkg/rootless/rootless_linux.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'pkg') diff --git a/pkg/rootless/rootless_linux.c b/pkg/rootless/rootless_linux.c index d93e4c10c..7a2bf0377 100644 --- a/pkg/rootless/rootless_linux.c +++ b/pkg/rootless/rootless_linux.c @@ -233,9 +233,8 @@ int is_fd_inherited(int fd) { if (open_files_set == NULL || fd > open_files_max_fd || fd < 0) - { return 0; - } + return FD_ISSET(fd % FD_SETSIZE, &(open_files_set[fd / FD_SETSIZE])) ? 1 : 0; } @@ -633,9 +632,10 @@ reexec_userns_join (int pid_to_join, char *pause_pid_file_path) close (user_ns); close (mnt_ns); - for (f = 3; f < open_files_max_fd; f++) - if (open_files_set == NULL || FD_ISSET (f % FD_SETSIZE, &(open_files_set[f / FD_SETSIZE]))) + for (f = 3; f <= open_files_max_fd; f++) + if (is_fd_inherited (f)) close (f); + return pid; } @@ -813,13 +813,14 @@ reexec_in_user_namespace (int ready, char *pause_pid_file_path, char *file_to_re if (do_socket_activation) { long num_fds; + num_fds = strtol (listen_fds, NULL, 10); if (num_fds != LONG_MIN && num_fds != LONG_MAX) { int f; for (f = 3; f < num_fds + 3; f++) - if (open_files_set == NULL || FD_ISSET (f % FD_SETSIZE, &(open_files_set[f / FD_SETSIZE]))) + if (is_fd_inherited (f)) close (f); } unsetenv ("LISTEN_PID"); -- cgit v1.2.3-54-g00ecf From c8130be174e0f5209661ab454bee37a3765d1b04 Mon Sep 17 00:00:00 2001 From: pendulm Date: Fri, 2 Apr 2021 19:33:05 +0800 Subject: Move socket activation check into init() and set global condition. So rootless setup could use this condition in parent and child, child podman should adjust LISTEN_PID to its self PID. Add system test for systemd socket activation Signed-off-by: pendulm --- pkg/rootless/rootless_linux.c | 58 +++++++++++++++---- test/system/270-socket-activation.bats | 103 +++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+), 12 deletions(-) create mode 100644 test/system/270-socket-activation.bats (limited to 'pkg') diff --git a/pkg/rootless/rootless_linux.c b/pkg/rootless/rootless_linux.c index 7a2bf0377..918b9a7e6 100644 --- a/pkg/rootless/rootless_linux.c +++ b/pkg/rootless/rootless_linux.c @@ -61,6 +61,10 @@ static int open_files_max_fd; static fd_set *open_files_set; static uid_t rootless_uid_init; static gid_t rootless_gid_init; +static bool do_socket_activation = false; +static char *saved_systemd_listen_fds; +static char *saved_systemd_listen_pid; +static char *saved_systemd_listen_fdnames; static int syscall_setresuid (uid_t ruid, uid_t euid, uid_t suid) @@ -242,6 +246,10 @@ static void __attribute__((constructor)) init() { const char *xdg_runtime_dir; const char *pause; + const char *listen_pid; + const char *listen_fds; + const char *listen_fdnames; + DIR *d; pause = getenv ("_PODMAN_PAUSE"); @@ -293,6 +301,26 @@ static void __attribute__((constructor)) init() closedir (d); } + listen_pid = getenv("LISTEN_PID"); + listen_fds = getenv("LISTEN_FDS"); + listen_fdnames = getenv("LISTEN_FDNAMES"); + + if (listen_pid != NULL && listen_fds != NULL && strtol(listen_pid, NULL, 10) == getpid()) + { + // save systemd socket environment for rootless child + do_socket_activation = true; + saved_systemd_listen_pid = strdup(listen_pid); + saved_systemd_listen_fds = strdup(listen_fds); + saved_systemd_listen_fdnames = strdup(listen_fdnames); + if (saved_systemd_listen_pid == NULL + || saved_systemd_listen_fds == NULL + || saved_systemd_listen_fdnames == NULL) + { + fprintf (stderr, "save socket listen environments error: %s\n", strerror (errno)); + _exit (EXIT_FAILURE); + } + } + /* Shortcut. If we are able to join the pause pid file, do it now so we don't need to re-exec. */ xdg_runtime_dir = getenv ("XDG_RUNTIME_DIR"); @@ -635,6 +663,12 @@ reexec_userns_join (int pid_to_join, char *pause_pid_file_path) for (f = 3; f <= open_files_max_fd; f++) if (is_fd_inherited (f)) close (f); + if (do_socket_activation) + { + unsetenv ("LISTEN_PID"); + unsetenv ("LISTEN_FDS"); + unsetenv ("LISTEN_FDNAMES"); + } return pid; } @@ -660,6 +694,15 @@ reexec_userns_join (int pid_to_join, char *pause_pid_file_path) _exit (EXIT_FAILURE); } + if (do_socket_activation) + { + char s[32]; + sprintf (s, "%d", getpid()); + setenv ("LISTEN_PID", s, true); + setenv ("LISTEN_FDS", saved_systemd_listen_fds, true); + setenv ("LISTEN_FDNAMES", saved_systemd_listen_fdnames, true); + } + setenv ("_CONTAINERS_USERNS_CONFIGURED", "init", 1); setenv ("_CONTAINERS_ROOTLESS_UID", uid, 1); setenv ("_CONTAINERS_ROOTLESS_GID", gid, 1); @@ -777,9 +820,6 @@ reexec_in_user_namespace (int ready, char *pause_pid_file_path, char *file_to_re char **argv; char uid[16]; char gid[16]; - char *listen_fds = NULL; - char *listen_pid = NULL; - bool do_socket_activation = false; char *cwd = getcwd (NULL, 0); sigset_t sigset, oldsigset; @@ -789,14 +829,6 @@ reexec_in_user_namespace (int ready, char *pause_pid_file_path, char *file_to_re _exit (EXIT_FAILURE); } - listen_pid = getenv("LISTEN_PID"); - listen_fds = getenv("LISTEN_FDS"); - - if (listen_pid != NULL && listen_fds != NULL) - { - if (strtol(listen_pid, NULL, 10) == getpid()) - do_socket_activation = true; - } sprintf (uid, "%d", geteuid ()); sprintf (gid, "%d", getegid ()); @@ -814,7 +846,7 @@ reexec_in_user_namespace (int ready, char *pause_pid_file_path, char *file_to_re { long num_fds; - num_fds = strtol (listen_fds, NULL, 10); + num_fds = strtol (saved_systemd_listen_fds, NULL, 10); if (num_fds != LONG_MIN && num_fds != LONG_MAX) { int f; @@ -863,6 +895,8 @@ reexec_in_user_namespace (int ready, char *pause_pid_file_path, char *file_to_re char s[32]; sprintf (s, "%d", getpid()); setenv ("LISTEN_PID", s, true); + setenv ("LISTEN_FDS", saved_systemd_listen_fds, true); + setenv ("LISTEN_FDNAMES", saved_systemd_listen_fdnames, true); } setenv ("_CONTAINERS_USERNS_CONFIGURED", "init", 1); diff --git a/test/system/270-socket-activation.bats b/test/system/270-socket-activation.bats new file mode 100644 index 000000000..25206c6a7 --- /dev/null +++ b/test/system/270-socket-activation.bats @@ -0,0 +1,103 @@ +#!/usr/bin/env bats -*- bats -*- +# +# Tests podman system service under systemd socket activation +# + +load helpers + +SERVICE_NAME="podman_test_$(random_string)" + +SYSTEMCTL="systemctl" +UNIT_DIR="/usr/lib/systemd/system" +SERVICE_SOCK_ADDR="/run/podman/podman.sock" + +if is_rootless; then + UNIT_DIR="$HOME/.config/systemd/user" + mkdir -p $UNIT_DIR + + SYSTEMCTL="$SYSTEMCTL --user" + if [ -z "$XDG_RUNTIME_DIR" ]; then + export XDG_RUNTIME_DIR=/run/user/$(id -u) + fi + SERVICE_SOCK_ADDR="$XDG_RUNTIME_DIR/podman/podman.sock" +fi + +SERVICE_FILE="$UNIT_DIR/$SERVICE_NAME.service" +SOCKET_FILE="$UNIT_DIR/$SERVICE_NAME.socket" + + +function setup() { + skip_if_remote "systemd tests are meaningless over remote" + + basic_setup + + cat > $SERVICE_FILE < $SOCKET_FILE < /dev/null + rm -f $pause_pid + fi + fi + $SYSTEMCTL start "$SERVICE_NAME.socket" +} + +function teardown() { + $SYSTEMCTL stop "$SERVICE_NAME.socket" + rm -f "$SERVICE_FILE" "$SOCKET_FILE" + $SYSTEMCTL daemon-reload + basic_teardown +} + +@test "podman system service - socket activation - no container" { + run curl -s --max-time 3 --unix-socket $SERVICE_SOCK_ADDR http://podman/libpod/_ping + is "$output" "OK" "podman service responses normally" +} + +@test "podman system service - socket activation - exist container " { + run_podman run $IMAGE sleep 90 + run curl -s --max-time 3 --unix-socket $SERVICE_SOCK_ADDR http://podman/libpod/_ping + is "$output" "OK" "podman service responses normally" +} + +@test "podman system service - socket activation - kill rootless pause " { + if ! is_rootless; then + skip "root podman no need pause process" + fi + run_podman run $IMAGE sleep 90 + local pause_pid="$XDG_RUNTIME_DIR/libpod/tmp/pause.pid" + if [ -f $pause_pid ]; then + kill -9 $(cat $pause_pid) 2> /dev/null + fi + run curl -s --max-time 3 --unix-socket $SERVICE_SOCK_ADDR http://podman/libpod/_ping + is "$output" "OK" "podman service responses normally" +} + +# vim: filetype=sh -- cgit v1.2.3-54-g00ecf From 32f61dbf73538ea97a0cdabb6593c5a2b96f7171 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Mon, 29 Mar 2021 09:49:38 -0400 Subject: [NO TESTS NEEDED] Shrink the size of podman-remote Signed-off-by: Daniel J Walsh --- cmd/podman/images/build.go | 34 +++++------ libpod/events/logfile.go | 4 +- libpod/runtime_img.go | 3 +- pkg/api/handlers/compat/images_build.go | 11 ++-- pkg/api/handlers/compat/version.go | 6 +- pkg/api/handlers/types.go | 4 -- pkg/api/handlers/types/types.go | 23 ++++++++ pkg/bindings/images/build.go | 1 - pkg/bindings/images/images.go | 6 +- pkg/bindings/images/rm.go | 4 +- pkg/bindings/images/types.go | 4 +- pkg/domain/entities/images.go | 41 +++++++------- pkg/domain/entities/system.go | 2 +- pkg/domain/entities/types.go | 4 +- pkg/domain/entities/types/auth.go | 22 ++++++++ pkg/domain/entities/types/types.go | 28 ++++++++++ pkg/domain/entities/volumes.go | 96 ++++++++++++++++++++++++++++++-- pkg/domain/infra/runtime_libpod.go | 8 +-- pkg/namespaces/namespaces.go | 10 ++-- pkg/rootless/rootless.go | 4 +- pkg/specgen/generate/container_create.go | 4 +- pkg/specgen/specgen.go | 4 +- pkg/util/utils.go | 14 ++--- 23 files changed, 245 insertions(+), 92 deletions(-) create mode 100644 pkg/api/handlers/types/types.go create mode 100644 pkg/domain/entities/types/auth.go create mode 100644 pkg/domain/entities/types/types.go (limited to 'pkg') diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index 7bb05e9b1..04fdeab0a 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/containers/buildah/define" + buildahDefine "github.com/containers/buildah/define" buildahCLI "github.com/containers/buildah/pkg/cli" "github.com/containers/buildah/pkg/parse" "github.com/containers/common/pkg/auth" @@ -159,11 +159,11 @@ func buildFlags(cmd *cobra.Command) { flags.SetNormalizeFunc(buildahCLI.AliasFlags) if registry.IsRemote() { flag = flags.Lookup("isolation") - buildOpts.Isolation = define.OCI - if err := flag.Value.Set(define.OCI); err != nil { - logrus.Errorf("unable to set --isolation to %v: %v", define.OCI, err) + buildOpts.Isolation = buildahDefine.OCI + if err := flag.Value.Set(buildahDefine.OCI); err != nil { + logrus.Errorf("unable to set --isolation to %v: %v", buildahDefine.OCI, err) } - flag.DefValue = define.OCI + flag.DefValue = buildahDefine.OCI _ = flags.MarkHidden("disable-content-trust") _ = flags.MarkHidden("cache-from") _ = flags.MarkHidden("sign-by") @@ -196,7 +196,7 @@ func build(cmd *cobra.Command, args []string) error { var contextDir string if len(args) > 0 { // The context directory could be a URL. Try to handle that. - tempDir, subDir, err := define.TempDirForURL("", "buildah", args[0]) + tempDir, subDir, err := buildahDefine.TempDirForURL("", "buildah", args[0]) if err != nil { return errors.Wrapf(err, "error prepping temporary context directory") } @@ -319,16 +319,16 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil return nil, errors.Errorf("can only set one of 'pull' or 'pull-always' or 'pull-never'") } - pullPolicy := define.PullIfMissing + pullPolicy := buildahDefine.PullIfMissing if c.Flags().Changed("pull") && flags.Pull { - pullPolicy = define.PullAlways + pullPolicy = buildahDefine.PullAlways } if flags.PullAlways { - pullPolicy = define.PullAlways + pullPolicy = buildahDefine.PullAlways } if flags.PullNever { - pullPolicy = define.PullNever + pullPolicy = buildahDefine.PullNever } if c.Flag("authfile").Changed { @@ -409,9 +409,9 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil flags.Layers = false } - compression := define.Gzip + compression := buildahDefine.Gzip if flags.DisableCompression { - compression = define.Uncompressed + compression = buildahDefine.Uncompressed } isolation, err := parse.IsolationOption(flags.Isolation) @@ -433,10 +433,10 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil format := "" flags.Format = strings.ToLower(flags.Format) switch { - case strings.HasPrefix(flags.Format, define.OCI): - format = define.OCIv1ImageManifest - case strings.HasPrefix(flags.Format, define.DOCKER): - format = define.Dockerv2ImageManifest + case strings.HasPrefix(flags.Format, buildahDefine.OCI): + format = buildahDefine.OCIv1ImageManifest + case strings.HasPrefix(flags.Format, buildahDefine.DOCKER): + format = buildahDefine.Dockerv2ImageManifest default: return nil, errors.Errorf("unrecognized image type %q", flags.Format) } @@ -464,7 +464,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil return nil, errors.Wrapf(err, "unable to obtain decrypt config") } - opts := define.BuildOptions{ + opts := buildahDefine.BuildOptions{ AddCapabilities: flags.CapAdd, AdditionalTags: tags, Annotations: flags.Annotation, diff --git a/libpod/events/logfile.go b/libpod/events/logfile.go index 7a32ea311..0f00525e8 100644 --- a/libpod/events/logfile.go +++ b/libpod/events/logfile.go @@ -7,7 +7,7 @@ import ( "time" "github.com/containers/podman/v3/pkg/util" - "github.com/containers/storage" + "github.com/containers/storage/pkg/lockfile" "github.com/pkg/errors" ) @@ -20,7 +20,7 @@ type EventLogFile struct { // Writes to the log file func (e EventLogFile) Write(ee Event) error { // We need to lock events file - lock, err := storage.GetLockfile(e.options.LogFilePath + ".lock") + lock, err := lockfile.GetLockfile(e.options.LogFilePath + ".lock") if err != nil { return err } diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index 8f49a18b6..3588467a5 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -9,6 +9,7 @@ import ( "net/url" "os" + buildahDefine "github.com/containers/buildah/define" "github.com/containers/buildah/imagebuildah" "github.com/containers/image/v5/directory" "github.com/containers/image/v5/docker/reference" @@ -165,7 +166,7 @@ func (r *Runtime) newImageBuildCompleteEvent(idOrName string) { } // Build adds the runtime to the imagebuildah call -func (r *Runtime) Build(ctx context.Context, options imagebuildah.BuildOptions, dockerfiles ...string) (string, reference.Canonical, error) { +func (r *Runtime) Build(ctx context.Context, options buildahDefine.BuildOptions, dockerfiles ...string) (string, reference.Canonical, error) { if options.Runtime == "" { options.Runtime = r.GetOCIRuntimePath() } diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 52012cde8..8cd993b8b 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -13,8 +13,7 @@ import ( "time" "github.com/containers/buildah" - "github.com/containers/buildah/define" - "github.com/containers/buildah/imagebuildah" + buildahDefine "github.com/containers/buildah/define" "github.com/containers/buildah/util" "github.com/containers/image/v5/types" "github.com/containers/podman/v3/libpod" @@ -277,13 +276,13 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { jobs = query.Jobs } - pullPolicy := define.PullIfMissing + pullPolicy := buildahDefine.PullIfMissing if utils.IsLibpodRequest(r) { - pullPolicy = define.PolicyMap[query.PullPolicy] + pullPolicy = buildahDefine.PolicyMap[query.PullPolicy] } else { if _, found := r.URL.Query()["pull"]; found { if query.Pull { - pullPolicy = define.PullAlways + pullPolicy = buildahDefine.PullAlways } } } @@ -315,7 +314,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()")) return } - buildOptions := imagebuildah.BuildOptions{ + buildOptions := buildahDefine.BuildOptions{ AddCapabilities: addCaps, AdditionalTags: additionalTags, Annotations: annotations, diff --git a/pkg/api/handlers/compat/version.go b/pkg/api/handlers/compat/version.go index fae147440..f1cd77a9a 100644 --- a/pkg/api/handlers/compat/version.go +++ b/pkg/api/handlers/compat/version.go @@ -10,8 +10,8 @@ import ( "github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/pkg/api/handlers/utils" "github.com/containers/podman/v3/pkg/domain/entities" + "github.com/containers/podman/v3/pkg/domain/entities/types" "github.com/containers/podman/v3/version" - docker "github.com/docker/docker/api/types" "github.com/pkg/errors" ) @@ -32,7 +32,7 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) { return } - components := []docker.ComponentVersion{{ + components := []types.ComponentVersion{{ Name: "Podman Engine", Version: versionInfo.Version, Details: map[string]string{ @@ -52,7 +52,7 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) { minVersion := version.APIVersion[version.Compat][version.MinimalAPI] utils.WriteResponse(w, http.StatusOK, entities.ComponentVersion{ - Version: docker.Version{ + Version: types.Version{ Platform: struct { Name string }{ diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go index f5eaf6f6d..736203171 100644 --- a/pkg/api/handlers/types.go +++ b/pkg/api/handlers/types.go @@ -28,10 +28,6 @@ type ContainerConfig struct { dockerContainer.Config } -type LibpodImagesLoadReport struct { - ID string `json:"id"` -} - type LibpodImagesPullReport struct { entities.ImagePullReport } diff --git a/pkg/api/handlers/types/types.go b/pkg/api/handlers/types/types.go new file mode 100644 index 000000000..71165364f --- /dev/null +++ b/pkg/api/handlers/types/types.go @@ -0,0 +1,23 @@ +package types + +import ( + "github.com/containers/podman/v3/pkg/domain/entities" +) + +// LibpodImagesRemoveReport is the return type for image removal via the rest +// api. +type LibpodImagesRemoveReport struct { + entities.ImageRemoveReport + // Image removal requires is to return data and an error. + Errors []string +} + +// HistoryResponse provides details on image layers +type HistoryResponse struct { + ID string `json:"Id"` + Created int64 + CreatedBy string + Tags []string + Size int64 + Comment string +} diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index 06aa838db..df4b150c4 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -174,7 +174,6 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO if len(platform) > 0 { params.Set("platform", platform) } - params.Set("pullpolicy", options.PullPolicy.String()) if options.Quiet { diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go index 1be2bdfdd..8680d6baa 100644 --- a/pkg/bindings/images/images.go +++ b/pkg/bindings/images/images.go @@ -8,7 +8,7 @@ import ( "net/url" "strconv" - "github.com/containers/podman/v3/pkg/api/handlers" + "github.com/containers/podman/v3/pkg/api/handlers/types" "github.com/containers/podman/v3/pkg/auth" "github.com/containers/podman/v3/pkg/bindings" "github.com/containers/podman/v3/pkg/domain/entities" @@ -96,12 +96,12 @@ func Tree(ctx context.Context, nameOrID string, options *TreeOptions) (*entities } // History returns the parent layers of an image. -func History(ctx context.Context, nameOrID string, options *HistoryOptions) ([]*handlers.HistoryResponse, error) { +func History(ctx context.Context, nameOrID string, options *HistoryOptions) ([]*types.HistoryResponse, error) { if options == nil { options = new(HistoryOptions) } _ = options - var history []*handlers.HistoryResponse + var history []*types.HistoryResponse conn, err := bindings.GetClient(ctx) if err != nil { return nil, err diff --git a/pkg/bindings/images/rm.go b/pkg/bindings/images/rm.go index beecce7bf..e45e583f4 100644 --- a/pkg/bindings/images/rm.go +++ b/pkg/bindings/images/rm.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "github.com/containers/podman/v3/pkg/api/handlers" + "github.com/containers/podman/v3/pkg/api/handlers/types" "github.com/containers/podman/v3/pkg/bindings" "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/errorhandling" @@ -19,7 +19,7 @@ func Remove(ctx context.Context, images []string, options *RemoveOptions) (*enti // FIXME - bindings tests are missing for this endpoint. Once the CI is // re-enabled for bindings, we need to add them. At the time of writing, // the tests don't compile. - var report handlers.LibpodImagesRemoveReport + var report types.LibpodImagesRemoveReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, []error{err} diff --git a/pkg/bindings/images/types.go b/pkg/bindings/images/types.go index 7bf70c82b..1f3e46729 100644 --- a/pkg/bindings/images/types.go +++ b/pkg/bindings/images/types.go @@ -1,7 +1,7 @@ package images import ( - "github.com/containers/buildah/imagebuildah" + buildahDefine "github.com/containers/buildah/define" ) //go:generate go run ../generator/generator.go RemoveOptions @@ -162,7 +162,7 @@ type PullOptions struct { //BuildOptions are optional options for building images type BuildOptions struct { - imagebuildah.BuildOptions + buildahDefine.BuildOptions } //go:generate go run ../generator/generator.go ExistsOptions diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go index 7999d8209..3cc46ed0a 100644 --- a/pkg/domain/entities/images.go +++ b/pkg/domain/entities/images.go @@ -8,33 +8,32 @@ import ( "github.com/containers/image/v5/types" "github.com/containers/podman/v3/pkg/inspect" "github.com/containers/podman/v3/pkg/trust" - docker "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/opencontainers/go-digest" v1 "github.com/opencontainers/image-spec/specs-go/v1" ) type Image struct { - ID string `json:"Id"` - RepoTags []string `json:",omitempty"` - RepoDigests []string `json:",omitempty"` - Parent string `json:",omitempty"` - Comment string `json:",omitempty"` - Created string `json:",omitempty"` - Container string `json:",omitempty"` - ContainerConfig *container.Config `json:",omitempty"` - DockerVersion string `json:",omitempty"` - Author string `json:",omitempty"` - Config *container.Config `json:",omitempty"` - Architecture string `json:",omitempty"` - Variant string `json:",omitempty"` - Os string `json:",omitempty"` - OsVersion string `json:",omitempty"` - Size int64 `json:",omitempty"` - VirtualSize int64 `json:",omitempty"` - GraphDriver docker.GraphDriverData `json:",omitempty"` - RootFS docker.RootFS `json:",omitempty"` - Metadata docker.ImageMetadata `json:",omitempty"` + ID string `json:"Id"` + RepoTags []string `json:",omitempty"` + RepoDigests []string `json:",omitempty"` + Parent string `json:",omitempty"` + Comment string `json:",omitempty"` + Created string `json:",omitempty"` + Container string `json:",omitempty"` + ContainerConfig *container.Config `json:",omitempty"` + DockerVersion string `json:",omitempty"` + Author string `json:",omitempty"` + Config *container.Config `json:",omitempty"` + Architecture string `json:",omitempty"` + Variant string `json:",omitempty"` + Os string `json:",omitempty"` + OsVersion string `json:",omitempty"` + Size int64 `json:",omitempty"` + VirtualSize int64 `json:",omitempty"` + GraphDriver string `json:",omitempty"` + RootFS string `json:",omitempty"` + Metadata string `json:",omitempty"` // Podman extensions Digest digest.Digest `json:",omitempty"` diff --git a/pkg/domain/entities/system.go b/pkg/domain/entities/system.go index 4b8383613..1a671d59e 100644 --- a/pkg/domain/entities/system.go +++ b/pkg/domain/entities/system.go @@ -5,7 +5,7 @@ import ( "github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/pkg/domain/entities/reports" - "github.com/docker/docker/api/types" + "github.com/containers/podman/v3/pkg/domain/entities/types" "github.com/spf13/cobra" ) diff --git a/pkg/domain/entities/types.go b/pkg/domain/entities/types.go index 9efc64c93..02e374111 100644 --- a/pkg/domain/entities/types.go +++ b/pkg/domain/entities/types.go @@ -3,7 +3,7 @@ package entities import ( "net" - "github.com/containers/buildah/imagebuildah" + buildahDefine "github.com/containers/buildah/define" "github.com/containers/podman/v3/libpod/events" "github.com/containers/podman/v3/pkg/specgen" "github.com/containers/storage/pkg/archive" @@ -91,7 +91,7 @@ type ContainerCreateResponse struct { // BuildOptions describe the options for building container images. type BuildOptions struct { - imagebuildah.BuildOptions + buildahDefine.BuildOptions } // BuildReport is the image-build report. diff --git a/pkg/domain/entities/types/auth.go b/pkg/domain/entities/types/auth.go new file mode 100644 index 000000000..ddf15bb18 --- /dev/null +++ b/pkg/domain/entities/types/auth.go @@ -0,0 +1,22 @@ +package types // import "github.com/docker/docker/api/types" + +// AuthConfig contains authorization information for connecting to a Registry +type AuthConfig struct { + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Auth string `json:"auth,omitempty"` + + // Email is an optional value associated with the username. + // This field is deprecated and will be removed in a later + // version of docker. + Email string `json:"email,omitempty"` + + ServerAddress string `json:"serveraddress,omitempty"` + + // IdentityToken is used to authenticate the user and get + // an access token for the registry. + IdentityToken string `json:"identitytoken,omitempty"` + + // RegistryToken is a bearer token to be sent to a registry + RegistryToken string `json:"registrytoken,omitempty"` +} diff --git a/pkg/domain/entities/types/types.go b/pkg/domain/entities/types/types.go new file mode 100644 index 000000000..77834c0cb --- /dev/null +++ b/pkg/domain/entities/types/types.go @@ -0,0 +1,28 @@ +package types // import "github.com/docker/docker/api/types" + +// ComponentVersion describes the version information for a specific component. +type ComponentVersion struct { + Name string + Version string + Details map[string]string `json:",omitempty"` +} + +// Version contains response of Engine API: +// GET "/version" +type Version struct { + Platform struct{ Name string } `json:",omitempty"` + Components []ComponentVersion `json:",omitempty"` + + // The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility + + Version string + APIVersion string `json:"ApiVersion"` + MinAPIVersion string `json:"MinAPIVersion,omitempty"` + GitCommit string + GoVersion string + Os string + Arch string + KernelVersion string `json:",omitempty"` + Experimental bool `json:",omitempty"` + BuildTime string `json:",omitempty"` +} diff --git a/pkg/domain/entities/volumes.go b/pkg/domain/entities/volumes.go index beb2a75ac..55a6a1b14 100644 --- a/pkg/domain/entities/volumes.go +++ b/pkg/domain/entities/volumes.go @@ -4,10 +4,72 @@ import ( "net/url" "github.com/containers/podman/v3/libpod/define" - docker_api_types "github.com/docker/docker/api/types" - docker_api_types_volume "github.com/docker/docker/api/types/volume" ) +// Volume volume +// swagger:model Volume +type volume struct { + + // Date/Time the volume was created. + CreatedAt string `json:"CreatedAt,omitempty"` + + // Name of the volume driver used by the volume. + // Required: true + Driver string `json:"Driver"` + + // User-defined key/value metadata. + // Required: true + Labels map[string]string `json:"Labels"` + + // Mount path of the volume on the host. + // Required: true + Mountpoint string `json:"Mountpoint"` + + // Name of the volume. + // Required: true + Name string `json:"Name"` + + // The driver specific options used when creating the volume. + // + // Required: true + Options map[string]string `json:"Options"` + + // The level at which the volume exists. Either `global` for cluster-wide, + // or `local` for machine level. + // + // Required: true + Scope string `json:"Scope"` + + // Low-level details about the volume, provided by the volume driver. + // Details are returned as a map with key/value pairs: + // `{"key":"value","key2":"value2"}`. + // + // The `Status` field is optional, and is omitted if the volume driver + // does not support this feature. + // + Status map[string]interface{} `json:"Status,omitempty"` + + // usage data + UsageData *VolumeUsageData `json:"UsageData,omitempty"` +} + +type VolumeUsageData struct { + + // The number of containers referencing this volume. This field + // is set to `-1` if the reference-count is not available. + // + // Required: true + RefCount int64 `json:"RefCount"` + + // Amount of disk space used by the volume (in bytes). This information + // is only available for volumes created with the `"local"` volume + // driver. For volumes created with other volume drivers, this field + // is set to `-1` ("not available") + // + // Required: true + Size int64 `json:"Size"` +} + // swagger:model VolumeCreate type VolumeCreateOptions struct { // New volume's name. Can be left blank @@ -113,14 +175,14 @@ type SwagVolumeListResponse struct { */ // swagger:model DockerVolumeCreate -type DockerVolumeCreate docker_api_types_volume.VolumeCreateBody +type DockerVolumeCreate VolumeCreateBody // This response definition is used for both the create and inspect endpoints // swagger:response DockerVolumeInfoResponse type SwagDockerVolumeInfoResponse struct { // in:body Body struct { - docker_api_types.Volume + volume } } @@ -129,6 +191,30 @@ type SwagDockerVolumeInfoResponse struct { type SwagDockerVolumePruneResponse struct { // in:body Body struct { - docker_api_types.VolumesPruneReport + // docker_api_types.VolumesPruneReport } } + +// VolumeCreateBody Volume configuration +// swagger:model VolumeCreateBody +type VolumeCreateBody struct { + + // Name of the volume driver to use. + // Required: true + Driver string `json:"Driver"` + + // A mapping of driver options and values. These options are + // passed directly to the driver and are driver specific. + // + // Required: true + DriverOpts map[string]string `json:"DriverOpts"` + + // User-defined key/value metadata. + // Required: true + Labels map[string]string `json:"Labels"` + + // The new volume's name. If not specified, Docker generates a name. + // + // Required: true + Name string `json:"Name"` +} diff --git a/pkg/domain/infra/runtime_libpod.go b/pkg/domain/infra/runtime_libpod.go index 889a81acc..a98c9168a 100644 --- a/pkg/domain/infra/runtime_libpod.go +++ b/pkg/domain/infra/runtime_libpod.go @@ -15,8 +15,8 @@ import ( "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/namespaces" "github.com/containers/podman/v3/pkg/rootless" - "github.com/containers/storage" "github.com/containers/storage/pkg/idtools" + "github.com/containers/storage/types" "github.com/pkg/errors" "github.com/sirupsen/logrus" flag "github.com/spf13/pflag" @@ -100,7 +100,7 @@ func GetRuntimeNoStore(ctx context.Context, fs *flag.FlagSet, cfg *entities.Podm func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpod.Runtime, error) { options := []libpod.RuntimeOption{} - storageOpts := storage.StoreOptions{} + storageOpts := types.StoreOptions{} cfg := opts.config storageSet := false @@ -241,8 +241,8 @@ func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpo } // ParseIDMapping takes idmappings and subuid and subgid maps and returns a storage mapping -func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []string, subUIDMap, subGIDMap string) (*storage.IDMappingOptions, error) { - options := storage.IDMappingOptions{ +func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []string, subUIDMap, subGIDMap string) (*types.IDMappingOptions, error) { + options := types.IDMappingOptions{ HostUIDMapping: true, HostGIDMapping: true, } diff --git a/pkg/namespaces/namespaces.go b/pkg/namespaces/namespaces.go index c35f68e02..a7736aee0 100644 --- a/pkg/namespaces/namespaces.go +++ b/pkg/namespaces/namespaces.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/containers/storage" + "github.com/containers/storage/types" ) const ( @@ -109,12 +109,12 @@ func (n UsernsMode) IsDefaultValue() bool { // GetAutoOptions returns a AutoUserNsOptions with the settings to setup automatically // a user namespace. -func (n UsernsMode) GetAutoOptions() (*storage.AutoUserNsOptions, error) { +func (n UsernsMode) GetAutoOptions() (*types.AutoUserNsOptions, error) { parts := strings.SplitN(string(n), ":", 2) if parts[0] != "auto" { return nil, fmt.Errorf("wrong user namespace mode") } - options := storage.AutoUserNsOptions{} + options := types.AutoUserNsOptions{} if len(parts) == 1 { return &options, nil } @@ -131,13 +131,13 @@ func (n UsernsMode) GetAutoOptions() (*storage.AutoUserNsOptions, error) { } options.Size = uint32(s) case "uidmapping": - mapping, err := storage.ParseIDMapping([]string{v[1]}, nil, "", "") + mapping, err := types.ParseIDMapping([]string{v[1]}, nil, "", "") if err != nil { return nil, err } options.AdditionalUIDMappings = append(options.AdditionalUIDMappings, mapping.UIDMap...) case "gidmapping": - mapping, err := storage.ParseIDMapping(nil, []string{v[1]}, "", "") + mapping, err := types.ParseIDMapping(nil, []string{v[1]}, "", "") if err != nil { return nil, err } diff --git a/pkg/rootless/rootless.go b/pkg/rootless/rootless.go index b5538efc3..0b9d719a9 100644 --- a/pkg/rootless/rootless.go +++ b/pkg/rootless/rootless.go @@ -5,7 +5,7 @@ import ( "sort" "sync" - "github.com/containers/storage" + "github.com/containers/storage/pkg/lockfile" "github.com/opencontainers/runc/libcontainer/user" spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" @@ -25,7 +25,7 @@ func TryJoinPauseProcess(pausePidPath string) (bool, int, error) { } // It could not join the pause process, let's lock the file before trying to delete it. - pidFileLock, err := storage.GetLockfile(pausePidPath) + pidFileLock, err := lockfile.GetLockfile(pausePidPath) if err != nil { // The file was deleted by another process. if os.IsNotExist(err) { diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go index 03697b353..1d724ffb0 100644 --- a/pkg/specgen/generate/container_create.go +++ b/pkg/specgen/generate/container_create.go @@ -11,7 +11,7 @@ import ( "github.com/containers/podman/v3/libpod/image" "github.com/containers/podman/v3/pkg/specgen" "github.com/containers/podman/v3/pkg/util" - "github.com/containers/storage" + "github.com/containers/storage/types" "github.com/opencontainers/selinux/go-selinux/label" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -367,7 +367,7 @@ func createContainerOptions(ctx context.Context, rt *libpod.Runtime, s *specgen. return options, nil } -func CreateExitCommandArgs(storageConfig storage.StoreOptions, config *config.Config, syslog, rm, exec bool) ([]string, error) { +func CreateExitCommandArgs(storageConfig types.StoreOptions, config *config.Config, syslog, rm, exec bool) ([]string, error) { // We need a cleanup process for containers in the current model. // But we can't assume that the caller is Podman - it could be another // user of the API. diff --git a/pkg/specgen/specgen.go b/pkg/specgen/specgen.go index 732579bf0..c10dc5ef5 100644 --- a/pkg/specgen/specgen.go +++ b/pkg/specgen/specgen.go @@ -5,7 +5,7 @@ import ( "syscall" "github.com/containers/image/v5/manifest" - "github.com/containers/storage" + "github.com/containers/storage/types" spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" ) @@ -302,7 +302,7 @@ type ContainerSecurityConfig struct { // IDMappings are UID and GID mappings that will be used by user // namespaces. // Required if UserNS is private. - IDMappings *storage.IDMappingOptions `json:"idmappings,omitempty"` + IDMappings *types.IDMappingOptions `json:"idmappings,omitempty"` // ReadOnlyFilesystem indicates that everything will be mounted // as read-only ReadOnlyFilesystem bool `json:"read_only_filesystem,omitempty"` diff --git a/pkg/util/utils.go b/pkg/util/utils.go index a4c8f3a64..bbaf72981 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -20,8 +20,8 @@ import ( "github.com/containers/podman/v3/pkg/namespaces" "github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/signal" - "github.com/containers/storage" "github.com/containers/storage/pkg/idtools" + stypes "github.com/containers/storage/types" v1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" @@ -344,8 +344,8 @@ func ParseSignal(rawSignal string) (syscall.Signal, error) { } // GetKeepIDMapping returns the mappings and the user to use when keep-id is used -func GetKeepIDMapping() (*storage.IDMappingOptions, int, int, error) { - options := storage.IDMappingOptions{ +func GetKeepIDMapping() (*stypes.IDMappingOptions, int, int, error) { + options := stypes.IDMappingOptions{ HostUIDMapping: true, HostGIDMapping: true, } @@ -395,8 +395,8 @@ func GetKeepIDMapping() (*storage.IDMappingOptions, int, int, error) { } // ParseIDMapping takes idmappings and subuid and subgid maps and returns a storage mapping -func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []string, subUIDMap, subGIDMap string) (*storage.IDMappingOptions, error) { - options := storage.IDMappingOptions{ +func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []string, subUIDMap, subGIDMap string) (*stypes.IDMappingOptions, error) { + options := stypes.IDMappingOptions{ HostUIDMapping: true, HostGIDMapping: true, } @@ -479,7 +479,7 @@ type tomlConfig struct { } `toml:"storage"` } -func getTomlStorage(storeOptions *storage.StoreOptions) *tomlConfig { +func getTomlStorage(storeOptions *stypes.StoreOptions) *tomlConfig { config := new(tomlConfig) config.Storage.Driver = storeOptions.GraphDriverName @@ -496,7 +496,7 @@ func getTomlStorage(storeOptions *storage.StoreOptions) *tomlConfig { } // WriteStorageConfigFile writes the configuration to a file -func WriteStorageConfigFile(storageOpts *storage.StoreOptions, storageConf string) error { +func WriteStorageConfigFile(storageOpts *stypes.StoreOptions, storageConf string) error { if err := os.MkdirAll(filepath.Dir(storageConf), 0755); err != nil { return err } -- cgit v1.2.3-54-g00ecf From af5dba34b2a27313dcec57c2223b0e8f83799743 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 30 Mar 2021 06:39:49 -0400 Subject: Fix missing podman-remote build options Fix handling of SecurityOpts LabelOpts SeccompProfilePath ApparmorProfile Fix Ulimits Fixes: https://github.com/containers/podman/issues/9869 Signed-off-by: Daniel J Walsh --- pkg/api/handlers/compat/images_build.go | 202 ++++++++++++++++++++++---------- pkg/bindings/images/build.go | 32 +++++ test/system/070-build.bats | 40 +++++++ 3 files changed, 210 insertions(+), 64 deletions(-) (limited to 'pkg') diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 8cd993b8b..6f21ecf3d 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -10,6 +10,7 @@ import ( "os" "path/filepath" "strconv" + "strings" "time" "github.com/containers/buildah" @@ -63,52 +64,55 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { }() query := struct { - AddHosts string `schema:"extrahosts"` - AdditionalCapabilities string `schema:"addcaps"` - Annotations string `schema:"annotations"` - BuildArgs string `schema:"buildargs"` - CacheFrom string `schema:"cachefrom"` - Compression uint64 `schema:"compression"` - ConfigureNetwork string `schema:"networkmode"` - CpuPeriod uint64 `schema:"cpuperiod"` // nolint - CpuQuota int64 `schema:"cpuquota"` // nolint - CpuSetCpus string `schema:"cpusetcpus"` // nolint - CpuShares uint64 `schema:"cpushares"` // nolint - Devices string `schema:"devices"` - Dockerfile string `schema:"dockerfile"` - DropCapabilities string `schema:"dropcaps"` - DNSServers string `schema:"dnsservers"` - DNSOptions string `schema:"dnsoptions"` - DNSSearch string `schema:"dnssearch"` - Excludes string `schema:"excludes"` - ForceRm bool `schema:"forcerm"` - From string `schema:"from"` - HTTPProxy bool `schema:"httpproxy"` - Isolation string `schema:"isolation"` - Ignore bool `schema:"ignore"` - Jobs int `schema:"jobs"` // nolint - Labels string `schema:"labels"` - Layers bool `schema:"layers"` - LogRusage bool `schema:"rusage"` - Manifest string `schema:"manifest"` - MemSwap int64 `schema:"memswap"` - Memory int64 `schema:"memory"` - NamespaceOptions string `schema:"nsoptions"` - NoCache bool `schema:"nocache"` - OutputFormat string `schema:"outputformat"` - Platform string `schema:"platform"` - Pull bool `schema:"pull"` - PullPolicy string `schema:"pullpolicy"` - Quiet bool `schema:"q"` - Registry string `schema:"registry"` - Rm bool `schema:"rm"` - //FIXME SecurityOpt in remote API is not handled - SecurityOpt string `schema:"securityopt"` - ShmSize int `schema:"shmsize"` - Squash bool `schema:"squash"` - Tag []string `schema:"t"` - Target string `schema:"target"` - Timestamp int64 `schema:"timestamp"` + AddHosts string `schema:"extrahosts"` + AdditionalCapabilities string `schema:"addcaps"` + Annotations string `schema:"annotations"` + AppArmor string `schema:"apparmor"` + BuildArgs string `schema:"buildargs"` + CacheFrom string `schema:"cachefrom"` + Compression uint64 `schema:"compression"` + ConfigureNetwork string `schema:"networkmode"` + CpuPeriod uint64 `schema:"cpuperiod"` // nolint + CpuQuota int64 `schema:"cpuquota"` // nolint + CpuSetCpus string `schema:"cpusetcpus"` // nolint + CpuShares uint64 `schema:"cpushares"` // nolint + DNSOptions string `schema:"dnsoptions"` + DNSSearch string `schema:"dnssearch"` + DNSServers string `schema:"dnsservers"` + Devices string `schema:"devices"` + Dockerfile string `schema:"dockerfile"` + DropCapabilities string `schema:"dropcaps"` + Excludes string `schema:"excludes"` + ForceRm bool `schema:"forcerm"` + From string `schema:"from"` + HTTPProxy bool `schema:"httpproxy"` + Ignore bool `schema:"ignore"` + Isolation string `schema:"isolation"` + Jobs int `schema:"jobs"` // nolint + LabelOpts string `schema:"labelopts"` + Labels string `schema:"labels"` + Layers bool `schema:"layers"` + LogRusage bool `schema:"rusage"` + Manifest string `schema:"manifest"` + MemSwap int64 `schema:"memswap"` + Memory int64 `schema:"memory"` + NamespaceOptions string `schema:"nsoptions"` + NoCache bool `schema:"nocache"` + OutputFormat string `schema:"outputformat"` + Platform string `schema:"platform"` + Pull bool `schema:"pull"` + PullPolicy string `schema:"pullpolicy"` + Quiet bool `schema:"q"` + Registry string `schema:"registry"` + Rm bool `schema:"rm"` + Seccomp string `schema:"seccomp"` + SecurityOpt string `schema:"securityopt"` + ShmSize int `schema:"shmsize"` + Squash bool `schema:"squash"` + Tag []string `schema:"t"` + Target string `schema:"target"` + Timestamp int64 `schema:"timestamp"` + Ulimits string `schema:"ulimits"` }{ Dockerfile: "Dockerfile", Registry: "docker.io", @@ -123,7 +127,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { return } - // convert label formats + // convert addcaps formats var addCaps = []string{} if _, found := r.URL.Query()["addcaps"]; found { var m = []string{} @@ -133,6 +137,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { } addCaps = m } + addhosts := []string{} if _, found := r.URL.Query()["extrahosts"]; found { if err := json.Unmarshal([]byte(query.AddHosts), &addhosts); err != nil { @@ -142,7 +147,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { } compression := archive.Compression(query.Compression) - // convert label formats + + // convert dropcaps formats var dropCaps = []string{} if _, found := r.URL.Query()["dropcaps"]; found { var m = []string{} @@ -153,7 +159,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { dropCaps = m } - // convert label formats + // convert devices formats var devices = []string{} if _, found := r.URL.Query()["devices"]; found { var m = []string{} @@ -233,7 +239,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { } } - // convert label formats + // convert annotations formats var annotations = []string{} if _, found := r.URL.Query()["annotations"]; found { if err := json.Unmarshal([]byte(query.Annotations), &annotations); err != nil { @@ -242,7 +248,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { } } - // convert label formats + // convert nsoptions formats nsoptions := buildah.NamespaceOptions{} if _, found := r.URL.Query()["nsoptions"]; found { if err := json.Unmarshal([]byte(query.NamespaceOptions), &nsoptions); err != nil { @@ -271,11 +277,75 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { } } } + jobs := 1 if _, found := r.URL.Query()["jobs"]; found { jobs = query.Jobs } + var ( + labelOpts = []string{} + seccomp string + apparmor string + ) + + if utils.IsLibpodRequest(r) { + seccomp = query.Seccomp + apparmor = query.AppArmor + // convert labelopts formats + if _, found := r.URL.Query()["labelopts"]; found { + var m = []string{} + if err := json.Unmarshal([]byte(query.LabelOpts), &m); err != nil { + utils.BadRequest(w, "labelopts", query.LabelOpts, err) + return + } + labelOpts = m + } + } else { + // handle security-opt + if _, found := r.URL.Query()["securityopt"]; found { + var securityOpts = []string{} + if err := json.Unmarshal([]byte(query.SecurityOpt), &securityOpts); err != nil { + utils.BadRequest(w, "securityopt", query.SecurityOpt, err) + return + } + for _, opt := range securityOpts { + if opt == "no-new-privileges" { + utils.BadRequest(w, "securityopt", query.SecurityOpt, errors.New("no-new-privileges is not supported")) + return + } + con := strings.SplitN(opt, "=", 2) + if len(con) != 2 { + utils.BadRequest(w, "securityopt", query.SecurityOpt, errors.Errorf("Invalid --security-opt name=value pair: %q", opt)) + return + } + + switch con[0] { + case "label": + labelOpts = append(labelOpts, con[1]) + case "apparmor": + apparmor = con[1] + case "seccomp": + seccomp = con[1] + default: + utils.BadRequest(w, "securityopt", query.SecurityOpt, errors.Errorf("Invalid --security-opt 2: %q", opt)) + return + } + } + } + } + + // convert ulimits formats + var ulimits = []string{} + if _, found := r.URL.Query()["ulimits"]; found { + var m = []string{} + if err := json.Unmarshal([]byte(query.Ulimits), &m); err != nil { + utils.BadRequest(w, "ulimits", query.Ulimits, err) + return + } + ulimits = m + } + pullPolicy := buildahDefine.PullIfMissing if utils.IsLibpodRequest(r) { pullPolicy = buildahDefine.PolicyMap[query.PullPolicy] @@ -320,18 +390,22 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { Annotations: annotations, Args: buildArgs, CommonBuildOpts: &buildah.CommonBuildOptions{ - AddHost: addhosts, - CPUPeriod: query.CpuPeriod, - CPUQuota: query.CpuQuota, - CPUShares: query.CpuShares, - CPUSetCPUs: query.CpuSetCpus, - DNSServers: dnsservers, - DNSOptions: dnsoptions, - DNSSearch: dnssearch, - HTTPProxy: query.HTTPProxy, - Memory: query.Memory, - MemorySwap: query.MemSwap, - ShmSize: strconv.Itoa(query.ShmSize), + AddHost: addhosts, + ApparmorProfile: apparmor, + CPUPeriod: query.CpuPeriod, + CPUQuota: query.CpuQuota, + CPUSetCPUs: query.CpuSetCpus, + CPUShares: query.CpuShares, + DNSOptions: dnsoptions, + DNSSearch: dnssearch, + DNSServers: dnsservers, + HTTPProxy: query.HTTPProxy, + LabelOpts: labelOpts, + Memory: query.Memory, + MemorySwap: query.MemSwap, + SeccompProfilePath: seccomp, + ShmSize: strconv.Itoa(query.ShmSize), + Ulimit: ulimits, }, CNIConfigDir: rtc.Network.CNIPluginDirs[0], CNIPluginPath: util.DefaultCNIPluginPath, @@ -364,11 +438,11 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { RemoveIntermediateCtrs: query.Rm, ReportWriter: reporter, Squash: query.Squash, + Target: query.Target, SystemContext: &types.SystemContext{ AuthFilePath: authfile, DockerAuthConfig: creds, }, - Target: query.Target, } if _, found := r.URL.Query()["timestamp"]; found { diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index df4b150c4..51f902780 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -120,6 +120,9 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO if options.ForceRmIntermediateCtrs { params.Set("forcerm", "1") } + if options.RemoveIntermediateCtrs { + params.Set("rm", "1") + } if len(options.From) > 0 { params.Set("from", options.From) } @@ -140,6 +143,23 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO } params.Set("labels", l) } + + if opt := options.CommonBuildOpts.LabelOpts; len(opt) > 0 { + o, err := jsoniter.MarshalToString(opt) + if err != nil { + return nil, err + } + params.Set("labelopts", o) + } + + if len(options.CommonBuildOpts.SeccompProfilePath) > 0 { + params.Set("seccomp", options.CommonBuildOpts.SeccompProfilePath) + } + + if len(options.CommonBuildOpts.ApparmorProfile) > 0 { + params.Set("apparmor", options.CommonBuildOpts.ApparmorProfile) + } + if options.Layers { params.Set("layers", "1") } @@ -174,6 +194,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO if len(platform) > 0 { params.Set("platform", platform) } + params.Set("pullpolicy", options.PullPolicy.String()) if options.Quiet { @@ -182,6 +203,10 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO if options.RemoveIntermediateCtrs { params.Set("rm", "1") } + if len(options.Target) > 0 { + params.Set("target", options.Target) + } + if hosts := options.CommonBuildOpts.AddHost; len(hosts) > 0 { h, err := jsoniter.MarshalToString(hosts) if err != nil { @@ -212,6 +237,13 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO params.Set("timestamp", strconv.FormatInt(t.Unix(), 10)) } + if len(options.CommonBuildOpts.Ulimit) > 0 { + ulimitsJSON, err := json.Marshal(options.CommonBuildOpts.Ulimit) + if err != nil { + return nil, err + } + params.Set("ulimits", string(ulimitsJSON)) + } var ( headers map[string]string err error diff --git a/test/system/070-build.bats b/test/system/070-build.bats index e5b68a0d8..2e97c93e0 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -712,6 +712,46 @@ EOF run_podman rmi -f build_test } +@test "podman build check_label" { + skip_if_no_selinux + tmpdir=$PODMAN_TMPDIR/build-test + mkdir -p $tmpdir + tmpbuilddir=$tmpdir/build + mkdir -p $tmpbuilddir + dockerfile=$tmpbuilddir/Dockerfile + cat >$dockerfile <$dockerfile < Date: Wed, 27 Jan 2021 13:48:16 +0100 Subject: swagger: add operationIds that match with docker Signed-off-by: Tom Deseyn --- pkg/api/server/register_archive.go | 2 ++ pkg/api/server/register_containers.go | 20 +++++++++++++++++ pkg/api/server/register_events.go | 1 + pkg/api/server/register_exec.go | 4 ++++ pkg/api/server/register_images.go | 14 ++++++++++++ pkg/api/server/register_info.go | 1 + pkg/api/server/register_networks.go | 42 +++++++++++++++++++++++++++++++++++ pkg/api/server/register_version.go | 1 + pkg/api/server/register_volumes.go | 5 +++++ 9 files changed, 90 insertions(+) (limited to 'pkg') diff --git a/pkg/api/server/register_archive.go b/pkg/api/server/register_archive.go index 2ac126644..15933abbf 100644 --- a/pkg/api/server/register_archive.go +++ b/pkg/api/server/register_archive.go @@ -11,6 +11,7 @@ func (s *APIServer) registerArchiveHandlers(r *mux.Router) error { // swagger:operation PUT /containers/{name}/archive compat putArchive // --- // summary: Put files into a container + // operationId: PutContainerArchive // description: Put a tar archive of files into a container // tags: // - containers (compat) @@ -55,6 +56,7 @@ func (s *APIServer) registerArchiveHandlers(r *mux.Router) error { // swagger:operation GET /containers/{name}/archive compat getArchive // --- // summary: Get files from a container + // operationId: ContainerArchive // description: Get a tar archive of files from a container // tags: // - containers (compat) diff --git a/pkg/api/server/register_containers.go b/pkg/api/server/register_containers.go index 6813b834a..6044caf92 100644 --- a/pkg/api/server/register_containers.go +++ b/pkg/api/server/register_containers.go @@ -12,6 +12,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // swagger:operation POST /containers/create compat createContainer // --- // summary: Create a container + // operationId: ContainerCreate // tags: // - containers (compat) // produces: @@ -40,6 +41,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: List containers + // operationId: ContainerList // description: Returns a list of containers // parameters: // - in: query @@ -97,6 +99,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Delete stopped containers + // operationId: ContainerPrune // description: Remove containers not in use // parameters: // - in: query @@ -121,6 +124,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Remove a container + // operationId: ContainerDelete // parameters: // - in: path // name: name @@ -162,6 +166,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Inspect container + // operationId: ContainerInspect // description: Return low-level information about a container. // parameters: // - in: path @@ -191,6 +196,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Kill container + // operationId: ContainerKill // description: Signal to send to the container as an integer or string (e.g. SIGINT) // parameters: // - in: path @@ -228,6 +234,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Get container logs + // operationId: ContainerLogs // description: Get stdout and stderr logs from a container. // parameters: // - in: path @@ -282,6 +289,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Pause container + // operationId: ContainerPause // description: Use the cgroups freezer to suspend all processes in a container. // parameters: // - in: path @@ -306,6 +314,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Restart container + // operationId: ContainerRestart // parameters: // - in: path // name: name @@ -333,6 +342,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Start a container + // operationId: ContainerStart // parameters: // - in: path // name: name @@ -363,6 +373,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Get stats for a container + // operationId: ContainerStats // description: This returns a live stream of a container’s resource usage statistics. // parameters: // - in: path @@ -392,6 +403,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Stop a container + // operationId: ContainerStop // description: Stop a container // parameters: // - in: path @@ -422,6 +434,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: List processes running inside a container + // operationId: ContainerTop // parameters: // - in: path // name: name @@ -449,6 +462,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Unpause container + // operationId: ContainerUnpause // description: Resume a paused container // parameters: // - in: path @@ -473,6 +487,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Wait on a container + // operationId: ContainerWait // description: Block until a container stops or given condition is met. // parameters: // - in: path @@ -513,6 +528,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Attach to a container + // operationId: ContainerAttach // description: Hijacks the connection to forward the container's standard streams to the client. // parameters: // - in: path @@ -570,6 +586,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Resize a container's TTY + // operationId: ContainerResize // description: Resize the terminal attached to a container (for use with Attach). // parameters: // - in: path @@ -609,6 +626,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Export a container + // operationId: ContainerExport // description: Export the contents of a container as a tarball. // parameters: // - in: path @@ -632,6 +650,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: Rename an existing container + // operationId: ContainerRename // description: Change the name of an existing container. // parameters: // - in: path @@ -1486,6 +1505,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // - containers // - containers (compat) // summary: Report on changes to container's filesystem; adds, deletes or modifications. + // operationId: ContainerChanges // description: | // Returns which files in a container's filesystem have been added, deleted, or modified. The Kind of modification can be one of: // diff --git a/pkg/api/server/register_events.go b/pkg/api/server/register_events.go index acccebac1..008d8aa1a 100644 --- a/pkg/api/server/register_events.go +++ b/pkg/api/server/register_events.go @@ -13,6 +13,7 @@ func (s *APIServer) registerEventsHandlers(r *mux.Router) error { // tags: // - system (compat) // summary: Get events + // operationId: SystemEvents // description: Returns events filtered on query parameters // produces: // - application/json diff --git a/pkg/api/server/register_exec.go b/pkg/api/server/register_exec.go index de437ab1a..6f33d9784 100644 --- a/pkg/api/server/register_exec.go +++ b/pkg/api/server/register_exec.go @@ -13,6 +13,7 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // tags: // - exec (compat) // summary: Create an exec instance + // operationId: ContainerExec // description: Create an exec session to run a command inside a running container. Exec sessions will be automatically removed 5 minutes after they exit. // parameters: // - in: path @@ -82,6 +83,7 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // tags: // - exec (compat) // summary: Start an exec instance + // operationId: ExecStart // description: Starts a previously set up exec instance. If detach is true, this endpoint returns immediately after starting the command. Otherwise, it sets up an interactive session with the command. // parameters: // - in: path @@ -120,6 +122,7 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // tags: // - exec (compat) // summary: Resize an exec instance + // operationId: ExecResize // description: | // Resize the TTY session used by an exec instance. This endpoint only works if tty was specified as part of creating and starting the exec instance. // parameters: @@ -158,6 +161,7 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // tags: // - exec (compat) // summary: Inspect an exec instance + // operationId: ExecInspect // description: Return low-level information about an exec instance. // parameters: // - in: path diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index 423766bd8..9046cdd11 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -18,6 +18,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: Create an image + // operationId: ImageCreate // description: Create an image by either pulling it from a registry or importing it. // produces: // - application/json @@ -61,6 +62,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: List Images + // operationId: ImageList // description: Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image. // parameters: // - name: all @@ -98,6 +100,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: Import image + // operationId: ImageLoad // description: Load a set of images and tags into a repository. // parameters: // - in: query @@ -124,6 +127,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: Prune unused images + // operationId: ImagePrune // description: Remove images from local storage that are not being used by a container // parameters: // - in: query @@ -151,6 +155,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: Search images + // operationId: ImageSearch // description: Search registries for an image // parameters: // - in: query @@ -190,6 +195,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: Remove Image + // operationId: ImageDelete // description: Delete an image from local storage // parameters: // - in: path @@ -224,6 +230,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: Push Image + // operationId: ImagePush // description: Push an image to a container registry // parameters: // - in: path @@ -271,6 +278,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: Export an image + // operationId: ImageGet // description: Export an image in tarball format // parameters: // - in: path @@ -296,6 +304,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: Export several images + // operationId: ImageGetAll // description: Get a tarball containing all images and metadata for several image repositories // parameters: // - in: query @@ -321,6 +330,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: History of an image + // operationId: ImageHistory // description: Return parent layers of an image. // parameters: // - in: path @@ -345,6 +355,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: Inspect an image + // operationId: ImageInspect // description: Return low-level information about an image. // parameters: // - in: path @@ -369,6 +380,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: Tag an image + // operationId: ImageTag // description: Tag an image so that it becomes part of a repository. // parameters: // - in: path @@ -405,6 +417,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - containers (compat) // summary: New Image + // operationId: ImageCommit // description: Create a new image from a container // parameters: // - in: query @@ -453,6 +466,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // tags: // - images (compat) // summary: Create image + // operationId: ImageBuild // description: Build an image from the given Dockerfile(s) // parameters: // - in: query diff --git a/pkg/api/server/register_info.go b/pkg/api/server/register_info.go index c07d4699d..35000e7d7 100644 --- a/pkg/api/server/register_info.go +++ b/pkg/api/server/register_info.go @@ -14,6 +14,7 @@ func (s *APIServer) registerInfoHandlers(r *mux.Router) error { // tags: // - system (compat) // summary: Get info + // operationId: SystemInfo // description: Returns information on the system and libpod configuration // produces: // - application/json diff --git a/pkg/api/server/register_networks.go b/pkg/api/server/register_networks.go index 7710fb83f..f22f426c1 100644 --- a/pkg/api/server/register_networks.go +++ b/pkg/api/server/register_networks.go @@ -9,11 +9,26 @@ import ( ) func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { + // swagger:operation POST /networks/prune compat compatPruneNetwork + // --- + // tags: + // - networks (compat) + // Summary: Delete unused networks + // operationId: NetworkPrune + // description: Not supported + // produces: + // - application/json + // responses: + // 404: + // $ref: "#/responses/NoSuchNetwork" + r.HandleFunc(VersionedPath("/networks/prune"), compat.UnsupportedHandler).Methods(http.MethodPost) + r.HandleFunc("/networks/prune", compat.UnsupportedHandler).Methods(http.MethodPost) // swagger:operation DELETE /networks/{name} compat compatRemoveNetwork // --- // tags: // - networks (compat) // summary: Remove a network + // operationId: NetworkDelete // description: Remove a network // parameters: // - in: path @@ -37,6 +52,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // tags: // - networks (compat) // summary: Inspect a network + // operationId: NetworkInspect // description: Display low level configuration network // parameters: // - in: path @@ -60,6 +76,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // tags: // - networks (compat) // summary: List networks + // operationId: NetworkList // description: Display summary of network configurations // parameters: // - in: query @@ -85,6 +102,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // tags: // - networks (compat) // summary: Create network + // operationId: NetworkCreate // description: Create a network configuration // produces: // - application/json @@ -108,6 +126,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // tags: // - networks (compat) // summary: Connect container to network + // operationId: NetworkConnect // description: Connect a container to a network. This endpoint is current a no-op // produces: // - application/json @@ -136,6 +155,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // tags: // - networks (compat) // summary: Disconnect container from network + // operationId: NetworkDisconnect // description: Disconnect a container from a network. This endpoint is current a no-op // produces: // - application/json @@ -219,6 +239,28 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { */ r.HandleFunc(VersionedPath("/libpod/networks/{name}"), s.APIHandler(libpod.RemoveNetwork)).Methods(http.MethodDelete) + // swagger:operation GET /libpod/networks/{name}/json libpod libpodInspectNetwork + // --- + // tags: + // - networks + // summary: Inspect a network + // description: Display low level configuration for a CNI network + // parameters: + // - in: path + // name: name + // type: string + // required: true + // description: the name of the network + // produces: + // - application/json + // responses: + // 200: + // $ref: "#/responses/NetworkInspectReport" + // 404: + // $ref: "#/responses/NoSuchNetwork" + // 500: + // $ref: "#/responses/InternalError" + r.HandleFunc(VersionedPath("/libpod/networks/{name}/json"), s.APIHandler(libpod.InspectNetwork)).Methods(http.MethodGet) // swagger:operation GET /libpod/networks/{name}/exists libpod libpodExistsNetwork // --- // tags: diff --git a/pkg/api/server/register_version.go b/pkg/api/server/register_version.go index 0cedb5dc6..361412cd0 100644 --- a/pkg/api/server/register_version.go +++ b/pkg/api/server/register_version.go @@ -11,6 +11,7 @@ func (s *APIServer) registerVersionHandlers(r *mux.Router) error { // swagger:operation GET /version compat CompatSystemVersion // --- // summary: Component Version information + // operationId: SystemVersion // tags: // - system (compat) // produces: diff --git a/pkg/api/server/register_volumes.go b/pkg/api/server/register_volumes.go index b03f26487..caad0a7ae 100644 --- a/pkg/api/server/register_volumes.go +++ b/pkg/api/server/register_volumes.go @@ -153,6 +153,7 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // tags: // - volumes (compat) // summary: List volumes + // operationId: VolumeList // description: Returns a list of volume // produces: // - application/json @@ -181,6 +182,7 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // tags: // - volumes (compat) // summary: Create a volume + // operationId: VolumeCreate // parameters: // - in: body // name: create @@ -204,6 +206,7 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // tags: // - volumes (compat) // summary: Inspect volume + // operationId: VolumeInspect // parameters: // - in: path // name: name @@ -227,6 +230,7 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // tags: // - volumes (compat) // summary: Remove volume + // operationId: VolumeDelete // parameters: // - in: path // name: name @@ -259,6 +263,7 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // tags: // - volumes (compat) // summary: Prune volumes + // operationId: VolumePrune // produces: // - application/json // parameters: -- cgit v1.2.3-54-g00ecf From 430ecf41a1ea43e63e288d2d0a58565915c62de1 Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Wed, 3 Feb 2021 14:22:26 +0100 Subject: Move operationIds to swagger:operation line Signed-off-by: Tom Deseyn --- pkg/api/server/register_archive.go | 6 ++-- pkg/api/server/register_containers.go | 60 ++++++++++++----------------------- pkg/api/server/register_events.go | 3 +- pkg/api/server/register_exec.go | 12 +++---- pkg/api/server/register_images.go | 42 ++++++++---------------- pkg/api/server/register_info.go | 3 +- pkg/api/server/register_networks.go | 21 ++++-------- pkg/api/server/register_version.go | 3 +- pkg/api/server/register_volumes.go | 15 +++------ 9 files changed, 55 insertions(+), 110 deletions(-) (limited to 'pkg') diff --git a/pkg/api/server/register_archive.go b/pkg/api/server/register_archive.go index 15933abbf..af64bd993 100644 --- a/pkg/api/server/register_archive.go +++ b/pkg/api/server/register_archive.go @@ -8,10 +8,9 @@ import ( ) func (s *APIServer) registerArchiveHandlers(r *mux.Router) error { - // swagger:operation PUT /containers/{name}/archive compat putArchive + // swagger:operation PUT /containers/{name}/archive compat PutContainerArchive // --- // summary: Put files into a container - // operationId: PutContainerArchive // description: Put a tar archive of files into a container // tags: // - containers (compat) @@ -53,10 +52,9 @@ func (s *APIServer) registerArchiveHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" - // swagger:operation GET /containers/{name}/archive compat getArchive + // swagger:operation GET /containers/{name}/archive compat ContainerArchive // --- // summary: Get files from a container - // operationId: ContainerArchive // description: Get a tar archive of files from a container // tags: // - containers (compat) diff --git a/pkg/api/server/register_containers.go b/pkg/api/server/register_containers.go index 6044caf92..5710605d3 100644 --- a/pkg/api/server/register_containers.go +++ b/pkg/api/server/register_containers.go @@ -9,10 +9,9 @@ import ( ) func (s *APIServer) registerContainersHandlers(r *mux.Router) error { - // swagger:operation POST /containers/create compat createContainer + // swagger:operation POST /containers/create compat ContainerCreate // --- // summary: Create a container - // operationId: ContainerCreate // tags: // - containers (compat) // produces: @@ -36,12 +35,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/create"), s.APIHandler(compat.CreateContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/create", s.APIHandler(compat.CreateContainer)).Methods(http.MethodPost) - // swagger:operation GET /containers/json compat listContainers + // swagger:operation GET /containers/json compat ContainerList // --- // tags: // - containers (compat) // summary: List containers - // operationId: ContainerList // description: Returns a list of containers // parameters: // - in: query @@ -94,12 +92,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/json"), s.APIHandler(compat.ListContainers)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/json", s.APIHandler(compat.ListContainers)).Methods(http.MethodGet) - // swagger:operation POST /containers/prune compat pruneContainers + // swagger:operation POST /containers/prune compat ContainerPrune // --- // tags: // - containers (compat) // summary: Delete stopped containers - // operationId: ContainerPrune // description: Remove containers not in use // parameters: // - in: query @@ -119,12 +116,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/prune"), s.APIHandler(compat.PruneContainers)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/prune", s.APIHandler(compat.PruneContainers)).Methods(http.MethodPost) - // swagger:operation DELETE /containers/{name} compat removeContainer + // swagger:operation DELETE /containers/{name} compat ContainerDelete // --- // tags: // - containers (compat) // summary: Remove a container - // operationId: ContainerDelete // parameters: // - in: path // name: name @@ -161,12 +157,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}"), s.APIHandler(compat.RemoveContainer)).Methods(http.MethodDelete) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}", s.APIHandler(compat.RemoveContainer)).Methods(http.MethodDelete) - // swagger:operation GET /containers/{name}/json compat getContainer + // swagger:operation GET /containers/{name}/json compat ContainerInspect // --- // tags: // - containers (compat) // summary: Inspect container - // operationId: ContainerInspect // description: Return low-level information about a container. // parameters: // - in: path @@ -191,12 +186,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/json"), s.APIHandler(compat.GetContainer)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/json", s.APIHandler(compat.GetContainer)).Methods(http.MethodGet) - // swagger:operation POST /containers/{name}/kill compat killContainer + // swagger:operation POST /containers/{name}/kill compat ContainerKill // --- // tags: // - containers (compat) // summary: Kill container - // operationId: ContainerKill // description: Signal to send to the container as an integer or string (e.g. SIGINT) // parameters: // - in: path @@ -229,12 +223,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/kill"), s.APIHandler(compat.KillContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/kill", s.APIHandler(compat.KillContainer)).Methods(http.MethodPost) - // swagger:operation GET /containers/{name}/logs compat logsFromContainer + // swagger:operation GET /containers/{name}/logs compat ContainerLogs // --- // tags: // - containers (compat) // summary: Get container logs - // operationId: ContainerLogs // description: Get stdout and stderr logs from a container. // parameters: // - in: path @@ -284,12 +277,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/logs"), s.APIHandler(compat.LogsFromContainer)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/logs", s.APIHandler(compat.LogsFromContainer)).Methods(http.MethodGet) - // swagger:operation POST /containers/{name}/pause compat pauseContainer + // swagger:operation POST /containers/{name}/pause compat ContainerPause // --- // tags: // - containers (compat) // summary: Pause container - // operationId: ContainerPause // description: Use the cgroups freezer to suspend all processes in a container. // parameters: // - in: path @@ -309,12 +301,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/pause"), s.APIHandler(compat.PauseContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/pause", s.APIHandler(compat.PauseContainer)).Methods(http.MethodPost) - // swagger:operation POST /containers/{name}/restart compat restartContainer + // swagger:operation POST /containers/{name}/restart compat ContainerRestart // --- // tags: // - containers (compat) // summary: Restart container - // operationId: ContainerRestart // parameters: // - in: path // name: name @@ -337,12 +328,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/restart"), s.APIHandler(compat.RestartContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/restart", s.APIHandler(compat.RestartContainer)).Methods(http.MethodPost) - // swagger:operation POST /containers/{name}/start compat startContainer + // swagger:operation POST /containers/{name}/start compat ContainerStart // --- // tags: // - containers (compat) // summary: Start a container - // operationId: ContainerStart // parameters: // - in: path // name: name @@ -368,12 +358,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/start"), s.APIHandler(compat.StartContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/start", s.APIHandler(compat.StartContainer)).Methods(http.MethodPost) - // swagger:operation GET /containers/{name}/stats compat statsContainer + // swagger:operation GET /containers/{name}/stats compat ContainerStats // --- // tags: // - containers (compat) // summary: Get stats for a container - // operationId: ContainerStats // description: This returns a live stream of a container’s resource usage statistics. // parameters: // - in: path @@ -398,12 +387,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/stats"), s.APIHandler(compat.StatsContainer)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/stats", s.APIHandler(compat.StatsContainer)).Methods(http.MethodGet) - // swagger:operation POST /containers/{name}/stop compat stopContainer + // swagger:operation POST /containers/{name}/stop compat ContainerStop // --- // tags: // - containers (compat) // summary: Stop a container - // operationId: ContainerStop // description: Stop a container // parameters: // - in: path @@ -429,12 +417,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/stop"), s.APIHandler(compat.StopContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/stop", s.APIHandler(compat.StopContainer)).Methods(http.MethodPost) - // swagger:operation GET /containers/{name}/top compat topContainer + // swagger:operation GET /containers/{name}/top compat ContainerTop // --- // tags: // - containers (compat) // summary: List processes running inside a container - // operationId: ContainerTop // parameters: // - in: path // name: name @@ -457,12 +444,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/top"), s.APIHandler(compat.TopContainer)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/top", s.APIHandler(compat.TopContainer)).Methods(http.MethodGet) - // swagger:operation POST /containers/{name}/unpause compat unpauseContainer + // swagger:operation POST /containers/{name}/unpause compat ContainerUnpause // --- // tags: // - containers (compat) // summary: Unpause container - // operationId: ContainerUnpause // description: Resume a paused container // parameters: // - in: path @@ -482,12 +468,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/unpause"), s.APIHandler(compat.UnpauseContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/unpause", s.APIHandler(compat.UnpauseContainer)).Methods(http.MethodPost) - // swagger:operation POST /containers/{name}/wait compat waitContainer + // swagger:operation POST /containers/{name}/wait compat ContainerWait // --- // tags: // - containers (compat) // summary: Wait on a container - // operationId: ContainerWait // description: Block until a container stops or given condition is met. // parameters: // - in: path @@ -523,12 +508,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/wait"), s.APIHandler(compat.WaitContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/wait", s.APIHandler(compat.WaitContainer)).Methods(http.MethodPost) - // swagger:operation POST /containers/{name}/attach compat attachContainer + // swagger:operation POST /containers/{name}/attach compat ContainerAttach // --- // tags: // - containers (compat) // summary: Attach to a container - // operationId: ContainerAttach // description: Hijacks the connection to forward the container's standard streams to the client. // parameters: // - in: path @@ -581,12 +565,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/attach"), s.APIHandler(compat.AttachContainer)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/attach", s.APIHandler(compat.AttachContainer)).Methods(http.MethodPost) - // swagger:operation POST /containers/{name}/resize compat resizeContainer + // swagger:operation POST /containers/{name}/resize compat ContainerResize // --- // tags: // - containers (compat) // summary: Resize a container's TTY - // operationId: ContainerResize // description: Resize the terminal attached to a container (for use with Attach). // parameters: // - in: path @@ -621,12 +604,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/resize"), s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.HandleFunc("/containers/{name}/resize", s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) - // swagger:operation GET /containers/{name}/export compat exportContainer + // swagger:operation GET /containers/{name}/export compat ContainerExport // --- // tags: // - containers (compat) // summary: Export a container - // operationId: ContainerExport // description: Export the contents of a container as a tarball. // parameters: // - in: path @@ -645,12 +627,11 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/containers/{name}/export"), s.APIHandler(compat.ExportContainer)).Methods(http.MethodGet) r.HandleFunc("/containers/{name}/export", s.APIHandler(compat.ExportContainer)).Methods(http.MethodGet) - // swagger:operation POST /containers/{name}/rename compat renameContainer + // swagger:operation POST /containers/{name}/rename compat ContainerRename // --- // tags: // - containers (compat) // summary: Rename an existing container - // operationId: ContainerRename // description: Change the name of an existing container. // parameters: // - in: path @@ -1498,14 +1479,13 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/restore"), s.APIHandler(libpod.Restore)).Methods(http.MethodPost) - // swagger:operation GET /containers/{name}/changes libpod libpodChangesContainer + // swagger:operation GET /containers/{name}/changes libpod ContainerChanges // swagger:operation GET /libpod/containers/{name}/changes compat changesContainer // --- // tags: // - containers // - containers (compat) // summary: Report on changes to container's filesystem; adds, deletes or modifications. - // operationId: ContainerChanges // description: | // Returns which files in a container's filesystem have been added, deleted, or modified. The Kind of modification can be one of: // diff --git a/pkg/api/server/register_events.go b/pkg/api/server/register_events.go index 008d8aa1a..01fc98377 100644 --- a/pkg/api/server/register_events.go +++ b/pkg/api/server/register_events.go @@ -8,12 +8,11 @@ import ( ) func (s *APIServer) registerEventsHandlers(r *mux.Router) error { - // swagger:operation GET /events system getEvents + // swagger:operation GET /events system SystemEvents // --- // tags: // - system (compat) // summary: Get events - // operationId: SystemEvents // description: Returns events filtered on query parameters // produces: // - application/json diff --git a/pkg/api/server/register_exec.go b/pkg/api/server/register_exec.go index 6f33d9784..715bdde10 100644 --- a/pkg/api/server/register_exec.go +++ b/pkg/api/server/register_exec.go @@ -8,12 +8,11 @@ import ( ) func (s *APIServer) registerExecHandlers(r *mux.Router) error { - // swagger:operation POST /containers/{name}/exec compat createExec + // swagger:operation POST /containers/{name}/exec compat ContainerExec // --- // tags: // - exec (compat) // summary: Create an exec instance - // operationId: ContainerExec // description: Create an exec session to run a command inside a running container. Exec sessions will be automatically removed 5 minutes after they exit. // parameters: // - in: path @@ -78,12 +77,11 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { r.Handle(VersionedPath("/containers/{name}/exec"), s.APIHandler(compat.ExecCreateHandler)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/containers/{name}/exec", s.APIHandler(compat.ExecCreateHandler)).Methods(http.MethodPost) - // swagger:operation POST /exec/{id}/start compat startExec + // swagger:operation POST /exec/{id}/start compat ExecStart // --- // tags: // - exec (compat) // summary: Start an exec instance - // operationId: ExecStart // description: Starts a previously set up exec instance. If detach is true, this endpoint returns immediately after starting the command. Otherwise, it sets up an interactive session with the command. // parameters: // - in: path @@ -117,12 +115,11 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { r.Handle(VersionedPath("/exec/{id}/start"), s.APIHandler(compat.ExecStartHandler)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/exec/{id}/start", s.APIHandler(compat.ExecStartHandler)).Methods(http.MethodPost) - // swagger:operation POST /exec/{id}/resize compat resizeExec + // swagger:operation POST /exec/{id}/resize compat ExecResize // --- // tags: // - exec (compat) // summary: Resize an exec instance - // operationId: ExecResize // description: | // Resize the TTY session used by an exec instance. This endpoint only works if tty was specified as part of creating and starting the exec instance. // parameters: @@ -156,12 +153,11 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { r.Handle(VersionedPath("/exec/{id}/resize"), s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/exec/{id}/resize", s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) - // swagger:operation GET /exec/{id}/json compat inspectExec + // swagger:operation GET /exec/{id}/json compat ExecInspect // --- // tags: // - exec (compat) // summary: Inspect an exec instance - // operationId: ExecInspect // description: Return low-level information about an exec instance. // parameters: // - in: path diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index 9046cdd11..b0423d200 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -13,12 +13,11 @@ import ( // * /images/create is missing the "message" and "platform" parameters func (s *APIServer) registerImagesHandlers(r *mux.Router) error { - // swagger:operation POST /images/create compat createImage + // swagger:operation POST /images/create compat ImageCreate // --- // tags: // - images (compat) // summary: Create an image - // operationId: ImageCreate // description: Create an image by either pulling it from a registry or importing it. // produces: // - application/json @@ -57,12 +56,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/create"), s.APIHandler(compat.CreateImageFromSrc)).Methods(http.MethodPost).Queries("fromSrc", "{fromSrc}") // Added non version path to URI to support docker non versioned paths r.Handle("/images/create", s.APIHandler(compat.CreateImageFromSrc)).Methods(http.MethodPost).Queries("fromSrc", "{fromSrc}") - // swagger:operation GET /images/json compat listImages + // swagger:operation GET /images/json compat ImageList // --- // tags: // - images (compat) // summary: List Images - // operationId: ImageList // description: Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image. // parameters: // - name: all @@ -95,12 +93,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/json"), s.APIHandler(compat.GetImages)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/json", s.APIHandler(compat.GetImages)).Methods(http.MethodGet) - // swagger:operation POST /images/load compat importImage + // swagger:operation POST /images/load compat ImageLoad // --- // tags: // - images (compat) // summary: Import image - // operationId: ImageLoad // description: Load a set of images and tags into a repository. // parameters: // - in: query @@ -122,12 +119,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/load"), s.APIHandler(compat.LoadImages)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/images/load", s.APIHandler(compat.LoadImages)).Methods(http.MethodPost) - // swagger:operation POST /images/prune compat pruneImages + // swagger:operation POST /images/prune compat ImagePrune // --- // tags: // - images (compat) // summary: Prune unused images - // operationId: ImagePrune // description: Remove images from local storage that are not being used by a container // parameters: // - in: query @@ -150,12 +146,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/prune"), s.APIHandler(compat.PruneImages)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/images/prune", s.APIHandler(compat.PruneImages)).Methods(http.MethodPost) - // swagger:operation GET /images/search compat searchImages + // swagger:operation GET /images/search compat ImageSearch // --- // tags: // - images (compat) // summary: Search images - // operationId: ImageSearch // description: Search registries for an image // parameters: // - in: query @@ -190,12 +185,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/search"), s.APIHandler(compat.SearchImages)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/search", s.APIHandler(compat.SearchImages)).Methods(http.MethodGet) - // swagger:operation DELETE /images/{name:.*} compat removeImage + // swagger:operation DELETE /images/{name:.*} compat ImageDelete // --- // tags: // - images (compat) // summary: Remove Image - // operationId: ImageDelete // description: Delete an image from local storage // parameters: // - in: path @@ -225,12 +219,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/{name:.*}"), s.APIHandler(compat.RemoveImage)).Methods(http.MethodDelete) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}", s.APIHandler(compat.RemoveImage)).Methods(http.MethodDelete) - // swagger:operation POST /images/{name:.*}/push compat pushImage + // swagger:operation POST /images/{name:.*}/push compat ImagePush // --- // tags: // - images (compat) // summary: Push Image - // operationId: ImagePush // description: Push an image to a container registry // parameters: // - in: path @@ -273,12 +266,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/{name:.*}/push"), s.APIHandler(compat.PushImage)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}/push", s.APIHandler(compat.PushImage)).Methods(http.MethodPost) - // swagger:operation GET /images/{name:.*}/get compat exportImage + // swagger:operation GET /images/{name:.*}/get compat ImageGet // --- // tags: // - images (compat) // summary: Export an image - // operationId: ImageGet // description: Export an image in tarball format // parameters: // - in: path @@ -299,12 +291,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/{name:.*}/get"), s.APIHandler(compat.ExportImage)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}/get", s.APIHandler(compat.ExportImage)).Methods(http.MethodGet) - // swagger:operation GET /images/get compat get + // swagger:operation GET /images/get compat ImageGetAll // --- // tags: // - images (compat) // summary: Export several images - // operationId: ImageGetAll // description: Get a tarball containing all images and metadata for several image repositories // parameters: // - in: query @@ -325,12 +316,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/get"), s.APIHandler(compat.ExportImages)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/get", s.APIHandler(compat.ExportImages)).Methods(http.MethodGet) - // swagger:operation GET /images/{name:.*}/history compat imageHistory + // swagger:operation GET /images/{name:.*}/history compat ImageHistory // --- // tags: // - images (compat) // summary: History of an image - // operationId: ImageHistory // description: Return parent layers of an image. // parameters: // - in: path @@ -350,12 +340,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/{name:.*}/history"), s.APIHandler(compat.HistoryImage)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}/history", s.APIHandler(compat.HistoryImage)).Methods(http.MethodGet) - // swagger:operation GET /images/{name:.*}/json compat inspectImage + // swagger:operation GET /images/{name:.*}/json compat ImageInspect // --- // tags: // - images (compat) // summary: Inspect an image - // operationId: ImageInspect // description: Return low-level information about an image. // parameters: // - in: path @@ -375,12 +364,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/{name:.*}/json"), s.APIHandler(compat.GetImage)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}/json", s.APIHandler(compat.GetImage)).Methods(http.MethodGet) - // swagger:operation POST /images/{name:.*}/tag compat tagImage + // swagger:operation POST /images/{name:.*}/tag compat ImageTag // --- // tags: // - images (compat) // summary: Tag an image - // operationId: ImageTag // description: Tag an image so that it becomes part of a repository. // parameters: // - in: path @@ -412,12 +400,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { r.Handle(VersionedPath("/images/{name:.*}/tag"), s.APIHandler(compat.TagImage)).Methods(http.MethodPost) // Added non version path to URI to support docker non versioned paths r.Handle("/images/{name:.*}/tag", s.APIHandler(compat.TagImage)).Methods(http.MethodPost) - // swagger:operation POST /commit compat commitContainer + // swagger:operation POST /commit compat ImageCommit // --- // tags: // - containers (compat) // summary: New Image - // operationId: ImageCommit // description: Create a new image from a container // parameters: // - in: query @@ -461,12 +448,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // Added non version path to URI to support docker non versioned paths r.Handle("/commit", s.APIHandler(compat.CommitContainer)).Methods(http.MethodPost) - // swagger:operation POST /build compat buildImage + // swagger:operation POST /build compat ImageBuild // --- // tags: // - images (compat) // summary: Create image - // operationId: ImageBuild // description: Build an image from the given Dockerfile(s) // parameters: // - in: query diff --git a/pkg/api/server/register_info.go b/pkg/api/server/register_info.go index 35000e7d7..ba4f3719c 100644 --- a/pkg/api/server/register_info.go +++ b/pkg/api/server/register_info.go @@ -9,12 +9,11 @@ import ( ) func (s *APIServer) registerInfoHandlers(r *mux.Router) error { - // swagger:operation GET /info compat getInfo + // swagger:operation GET /info compat SystemInfo // --- // tags: // - system (compat) // summary: Get info - // operationId: SystemInfo // description: Returns information on the system and libpod configuration // produces: // - application/json diff --git a/pkg/api/server/register_networks.go b/pkg/api/server/register_networks.go index f22f426c1..48456f3d6 100644 --- a/pkg/api/server/register_networks.go +++ b/pkg/api/server/register_networks.go @@ -9,12 +9,11 @@ import ( ) func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { - // swagger:operation POST /networks/prune compat compatPruneNetwork + // swagger:operation POST /networks/prune compat NetworkPrune // --- // tags: // - networks (compat) // Summary: Delete unused networks - // operationId: NetworkPrune // description: Not supported // produces: // - application/json @@ -23,12 +22,11 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // $ref: "#/responses/NoSuchNetwork" r.HandleFunc(VersionedPath("/networks/prune"), compat.UnsupportedHandler).Methods(http.MethodPost) r.HandleFunc("/networks/prune", compat.UnsupportedHandler).Methods(http.MethodPost) - // swagger:operation DELETE /networks/{name} compat compatRemoveNetwork + // swagger:operation DELETE /networks/{name} compat NetworkDelete // --- // tags: // - networks (compat) // summary: Remove a network - // operationId: NetworkDelete // description: Remove a network // parameters: // - in: path @@ -47,12 +45,11 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/networks/{name}"), s.APIHandler(compat.RemoveNetwork)).Methods(http.MethodDelete) r.HandleFunc("/networks/{name}", s.APIHandler(compat.RemoveNetwork)).Methods(http.MethodDelete) - // swagger:operation GET /networks/{name} compat compatInspectNetwork + // swagger:operation GET /networks/{name} compat NetworkInspect // --- // tags: // - networks (compat) // summary: Inspect a network - // operationId: NetworkInspect // description: Display low level configuration network // parameters: // - in: path @@ -71,12 +68,11 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/networks/{name}"), s.APIHandler(compat.InspectNetwork)).Methods(http.MethodGet) r.HandleFunc("/networks/{name}", s.APIHandler(compat.InspectNetwork)).Methods(http.MethodGet) - // swagger:operation GET /networks compat compatListNetwork + // swagger:operation GET /networks compat NetworkList // --- // tags: // - networks (compat) // summary: List networks - // operationId: NetworkList // description: Display summary of network configurations // parameters: // - in: query @@ -97,12 +93,11 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/networks"), s.APIHandler(compat.ListNetworks)).Methods(http.MethodGet) r.HandleFunc("/networks", s.APIHandler(compat.ListNetworks)).Methods(http.MethodGet) - // swagger:operation POST /networks/create compat compatCreateNetwork + // swagger:operation POST /networks/create compat NetworkCreate // --- // tags: // - networks (compat) // summary: Create network - // operationId: NetworkCreate // description: Create a network configuration // produces: // - application/json @@ -121,12 +116,11 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/networks/create"), s.APIHandler(compat.CreateNetwork)).Methods(http.MethodPost) r.HandleFunc("/networks/create", s.APIHandler(compat.CreateNetwork)).Methods(http.MethodPost) - // swagger:operation POST /networks/{name}/connect compat compatConnectNetwork + // swagger:operation POST /networks/{name}/connect compat NetworkConnect // --- // tags: // - networks (compat) // summary: Connect container to network - // operationId: NetworkConnect // description: Connect a container to a network. This endpoint is current a no-op // produces: // - application/json @@ -150,12 +144,11 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/networks/{name}/connect"), s.APIHandler(compat.Connect)).Methods(http.MethodPost) r.HandleFunc("/networks/{name}/connect", s.APIHandler(compat.Connect)).Methods(http.MethodPost) - // swagger:operation POST /networks/{name}/disconnect compat compatDisconnectNetwork + // swagger:operation POST /networks/{name}/disconnect compat NetworkDisconnect // --- // tags: // - networks (compat) // summary: Disconnect container from network - // operationId: NetworkDisconnect // description: Disconnect a container from a network. This endpoint is current a no-op // produces: // - application/json diff --git a/pkg/api/server/register_version.go b/pkg/api/server/register_version.go index 361412cd0..71600e30d 100644 --- a/pkg/api/server/register_version.go +++ b/pkg/api/server/register_version.go @@ -8,10 +8,9 @@ import ( ) func (s *APIServer) registerVersionHandlers(r *mux.Router) error { - // swagger:operation GET /version compat CompatSystemVersion + // swagger:operation GET /version compat SystemVersion // --- // summary: Component Version information - // operationId: SystemVersion // tags: // - system (compat) // produces: diff --git a/pkg/api/server/register_volumes.go b/pkg/api/server/register_volumes.go index caad0a7ae..f100587b9 100644 --- a/pkg/api/server/register_volumes.go +++ b/pkg/api/server/register_volumes.go @@ -148,12 +148,11 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { * Docker compatibility endpoints */ - // swagger:operation GET /volumes compat listVolumes + // swagger:operation GET /volumes compat VolumeList // --- // tags: // - volumes (compat) // summary: List volumes - // operationId: VolumeList // description: Returns a list of volume // produces: // - application/json @@ -177,12 +176,11 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { r.Handle(VersionedPath("/volumes"), s.APIHandler(compat.ListVolumes)).Methods(http.MethodGet) r.Handle("/volumes", s.APIHandler(compat.ListVolumes)).Methods(http.MethodGet) - // swagger:operation POST /volumes/create compat createVolume + // swagger:operation POST /volumes/create compat VolumeCreate // --- // tags: // - volumes (compat) // summary: Create a volume - // operationId: VolumeCreate // parameters: // - in: body // name: create @@ -201,12 +199,11 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { r.Handle(VersionedPath("/volumes/create"), s.APIHandler(compat.CreateVolume)).Methods(http.MethodPost) r.Handle("/volumes/create", s.APIHandler(compat.CreateVolume)).Methods(http.MethodPost) - // swagger:operation GET /volumes/{name} compat inspectVolume + // swagger:operation GET /volumes/{name} compat VolumeInspect // --- // tags: // - volumes (compat) // summary: Inspect volume - // operationId: VolumeInspect // parameters: // - in: path // name: name @@ -225,12 +222,11 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { r.Handle(VersionedPath("/volumes/{name}"), s.APIHandler(compat.InspectVolume)).Methods(http.MethodGet) r.Handle("/volumes/{name}", s.APIHandler(compat.InspectVolume)).Methods(http.MethodGet) - // swagger:operation DELETE /volumes/{name} compat removeVolume + // swagger:operation DELETE /volumes/{name} compat VolumeDelete // --- // tags: // - volumes (compat) // summary: Remove volume - // operationId: VolumeDelete // parameters: // - in: path // name: name @@ -258,12 +254,11 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { r.Handle(VersionedPath("/volumes/{name}"), s.APIHandler(compat.RemoveVolume)).Methods(http.MethodDelete) r.Handle("/volumes/{name}", s.APIHandler(compat.RemoveVolume)).Methods(http.MethodDelete) - // swagger:operation POST /volumes/prune compat pruneVolumes + // swagger:operation POST /volumes/prune compat VolumePrune // --- // tags: // - volumes (compat) // summary: Prune volumes - // operationId: VolumePrune // produces: // - application/json // parameters: -- cgit v1.2.3-54-g00ecf From d42f6e3cd21867112471c768fb31123a92409166 Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Mon, 5 Apr 2021 17:13:15 -0700 Subject: [CI:DOCS] Set all operation id to be compatibile Libpod operation id's changed to better match compatibile id Builds on https://github.com/containers/podman/pull/9123 and corrects a duplicated ID. Signed-off-by: Jhon Honce --- pkg/api/server/docs.go | 12 +++---- pkg/api/server/register_archive.go | 4 +-- pkg/api/server/register_auth.go | 2 +- pkg/api/server/register_containers.go | 58 +++++++++++++++++----------------- pkg/api/server/register_events.go | 2 +- pkg/api/server/register_exec.go | 10 +++--- pkg/api/server/register_generate.go | 4 +-- pkg/api/server/register_healthcheck.go | 2 +- pkg/api/server/register_images.go | 47 ++++++++++++++------------- pkg/api/server/register_info.go | 2 +- pkg/api/server/register_manifest.go | 12 +++---- pkg/api/server/register_networks.go | 58 ++++++---------------------------- pkg/api/server/register_ping.go | 2 +- pkg/api/server/register_play.go | 2 +- pkg/api/server/register_pods.go | 28 ++++++++-------- pkg/api/server/register_secrets.go | 16 +++++----- pkg/api/server/register_system.go | 17 ++++++++-- pkg/api/server/register_version.go | 2 +- pkg/api/server/register_volumes.go | 12 +++---- pkg/api/tags.yaml | 2 +- 20 files changed, 135 insertions(+), 159 deletions(-) (limited to 'pkg') diff --git a/pkg/api/server/docs.go b/pkg/api/server/docs.go index a99fefd7b..e72b78221 100644 --- a/pkg/api/server/docs.go +++ b/pkg/api/server/docs.go @@ -1,4 +1,4 @@ -// Package api Provides a container compatible interface. +// Package api Provides an API for the Libpod library // // This documentation describes the Podman v2.0 RESTful API. // It replaces the Podman v1.0 API and was initially delivered @@ -21,22 +21,22 @@ // // 'podman info' // -// curl --unix-socket /run/podman/podman.sock http://d/v1.0.0/libpod/info +// curl --unix-socket /run/podman/podman.sock http://d/v3.0.0/libpod/info // // 'podman pull quay.io/containers/podman' // -// curl -XPOST --unix-socket /run/podman/podman.sock -v 'http://d/v1.0.0/images/create?fromImage=quay.io%2Fcontainers%2Fpodman' +// curl -XPOST --unix-socket /run/podman/podman.sock -v 'http://d/v3.0.0/images/create?fromImage=quay.io%2Fcontainers%2Fpodman' // // 'podman list images' // -// curl --unix-socket /run/podman/podman.sock -v 'http://d/v1.0.0/libpod/images/json' | jq +// curl --unix-socket /run/podman/podman.sock -v 'http://d/v3.0.0/libpod/images/json' | jq // // Terms Of Service: // // Schemes: http, https // Host: podman.io // BasePath: / -// Version: 0.0.1 +// Version: 3.2.0 // License: Apache-2.0 https://opensource.org/licenses/Apache-2.0 // Contact: Podman https://podman.io/community/ // @@ -47,8 +47,8 @@ // // Produces: // - application/json +// - application/octet-stream // - text/plain -// - text/html // // Consumes: // - application/json diff --git a/pkg/api/server/register_archive.go b/pkg/api/server/register_archive.go index af64bd993..ee7449fbb 100644 --- a/pkg/api/server/register_archive.go +++ b/pkg/api/server/register_archive.go @@ -91,7 +91,7 @@ func (s *APIServer) registerArchiveHandlers(r *mux.Router) error { Libpod */ - // swagger:operation PUT /libpod/containers/{name}/archive libpod libpodPutArchive + // swagger:operation PUT /libpod/containers/{name}/archive libpod PutContainerArchiveLibpod // --- // summary: Copy files into a container // description: Copy a tar archive of files into a container @@ -132,7 +132,7 @@ func (s *APIServer) registerArchiveHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" - // swagger:operation GET /libpod/containers/{name}/archive libpod libpodGetArchive + // swagger:operation GET /libpod/containers/{name}/archive libpod ContainerArchiveLibpod // --- // summary: Copy files from a container // description: Copy a tar archive of files from a container diff --git a/pkg/api/server/register_auth.go b/pkg/api/server/register_auth.go index 56e115e30..c07337653 100644 --- a/pkg/api/server/register_auth.go +++ b/pkg/api/server/register_auth.go @@ -8,7 +8,7 @@ import ( ) func (s *APIServer) registerAuthHandlers(r *mux.Router) error { - // swagger:operation POST /auth compat auth + // swagger:operation POST /auth compat SystemAuth // --- // summary: Check auth configuration // tags: diff --git a/pkg/api/server/register_containers.go b/pkg/api/server/register_containers.go index 5710605d3..6e64f32b2 100644 --- a/pkg/api/server/register_containers.go +++ b/pkg/api/server/register_containers.go @@ -662,7 +662,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { libpod endpoints */ - // swagger:operation POST /libpod/containers/create libpod libpodCreateContainer + // swagger:operation POST /libpod/containers/create libpod ContainerCreateLibpod // --- // summary: Create a container // tags: @@ -687,7 +687,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/create"), s.APIHandler(libpod.CreateContainer)).Methods(http.MethodPost) - // swagger:operation GET /libpod/containers/json libpod libpodListContainers + // swagger:operation GET /libpod/containers/json libpod ContainerListLibpod // --- // tags: // - containers @@ -752,7 +752,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/json"), s.APIHandler(libpod.ListContainers)).Methods(http.MethodGet) - // swagger:operation POST /libpod/containers/prune libpod libpodPruneContainers + // swagger:operation POST /libpod/containers/prune libpod ContainerPruneLibpod // --- // tags: // - containers @@ -774,7 +774,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/prune"), s.APIHandler(compat.PruneContainers)).Methods(http.MethodPost) - // swagger:operation GET /libpod/containers/showmounted libpod libpodShowMountedContainers + // swagger:operation GET /libpod/containers/showmounted libpod ShowMountedContainersLibpod // --- // tags: // - containers @@ -792,7 +792,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/showmounted"), s.APIHandler(libpod.ShowMountedContainers)).Methods(http.MethodGet) - // swagger:operation DELETE /libpod/containers/{name} libpod libpodRemoveContainer + // swagger:operation DELETE /libpod/containers/{name} libpod ContainerDeleteLibpod // --- // tags: // - containers @@ -826,7 +826,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}"), s.APIHandler(compat.RemoveContainer)).Methods(http.MethodDelete) - // swagger:operation GET /libpod/containers/{name}/json libpod libpodGetContainer + // swagger:operation GET /libpod/containers/{name}/json libpod ContainerInspectLibpod // --- // tags: // - containers @@ -852,7 +852,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/json"), s.APIHandler(libpod.GetContainer)).Methods(http.MethodGet) - // swagger:operation POST /libpod/containers/{name}/kill libpod libpodKillContainer + // swagger:operation POST /libpod/containers/{name}/kill libpod ContainerKillLibpod // --- // tags: // - containers @@ -881,7 +881,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/kill"), s.APIHandler(compat.KillContainer)).Methods(http.MethodPost) - // swagger:operation POST /libpod/containers/{name}/mount libpod libpodMountContainer + // swagger:operation POST /libpod/containers/{name}/mount libpod ContainerMountLibpod // --- // tags: // - containers @@ -907,7 +907,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/mount"), s.APIHandler(libpod.MountContainer)).Methods(http.MethodPost) - // swagger:operation POST /libpod/containers/{name}/unmount libpod libpodUnmountContainer + // swagger:operation POST /libpod/containers/{name}/unmount libpod ContainerUnmountLibpod // --- // tags: // - containers @@ -929,7 +929,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/unmount"), s.APIHandler(libpod.UnmountContainer)).Methods(http.MethodPost) - // swagger:operation GET /libpod/containers/{name}/logs libpod libpodLogsFromContainer + // swagger:operation GET /libpod/containers/{name}/logs libpod ContainerLogsLibpod // --- // tags: // - containers @@ -981,7 +981,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/logs"), s.APIHandler(compat.LogsFromContainer)).Methods(http.MethodGet) - // swagger:operation POST /libpod/containers/{name}/pause libpod libpodPauseContainer + // swagger:operation POST /libpod/containers/{name}/pause libpod ContainerPauseLibpod // --- // tags: // - containers @@ -1003,7 +1003,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // "$ref": "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/pause"), s.APIHandler(compat.PauseContainer)).Methods(http.MethodPost) - // swagger:operation POST /libpod/containers/{name}/restart libpod libpodRestartContainer + // swagger:operation POST /libpod/containers/{name}/restart libpod ContainerRestartLibpod // --- // tags: // - containers @@ -1028,7 +1028,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/restart"), s.APIHandler(compat.RestartContainer)).Methods(http.MethodPost) - // swagger:operation POST /libpod/containers/{name}/start libpod libpodStartContainer + // swagger:operation POST /libpod/containers/{name}/start libpod ContainerStartLibpod // --- // tags: // - containers @@ -1056,7 +1056,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/start"), s.APIHandler(compat.StartContainer)).Methods(http.MethodPost) - // swagger:operation GET /libpod/containers/{name}/stats libpod libpodStatsContainer + // swagger:operation GET /libpod/containers/{name}/stats libpod ContainerStatsLibpod // --- // tags: // - containers @@ -1083,7 +1083,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/stats"), s.APIHandler(compat.StatsContainer)).Methods(http.MethodGet) - // swagger:operation GET /libpod/containers/stats libpod libpodStatsContainers + // swagger:operation GET /libpod/containers/stats libpod ContainersStatsAllLibpod // --- // tags: // - containers @@ -1112,7 +1112,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/stats"), s.APIHandler(libpod.StatsContainer)).Methods(http.MethodGet) - // swagger:operation GET /libpod/containers/{name}/top libpod libpodTopContainer + // swagger:operation GET /libpod/containers/{name}/top libpod ContainerTopLibpod // --- // tags: // - containers @@ -1146,7 +1146,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/top"), s.APIHandler(compat.TopContainer)).Methods(http.MethodGet) - // swagger:operation POST /libpod/containers/{name}/unpause libpod libpodUnpauseContainer + // swagger:operation POST /libpod/containers/{name}/unpause libpod ContainerUnpauseLibpod // --- // tags: // - containers @@ -1167,7 +1167,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/unpause"), s.APIHandler(compat.UnpauseContainer)).Methods(http.MethodPost) - // swagger:operation POST /libpod/containers/{name}/wait libpod libpodWaitContainer + // swagger:operation POST /libpod/containers/{name}/wait libpod ContainerWaitLibpod // --- // tags: // - containers @@ -1215,7 +1215,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/wait"), s.APIHandler(libpod.WaitContainer)).Methods(http.MethodPost) - // swagger:operation GET /libpod/containers/{name}/exists libpod libpodContainerExists + // swagger:operation GET /libpod/containers/{name}/exists libpod ContainerExistsLibpod // --- // tags: // - containers @@ -1237,7 +1237,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/exists"), s.APIHandler(libpod.ContainerExists)).Methods(http.MethodGet) - // swagger:operation POST /libpod/containers/{name}/stop libpod libpodStopContainer + // swagger:operation POST /libpod/containers/{name}/stop libpod ContainerStopLibpod // --- // tags: // - containers @@ -1275,7 +1275,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/stop"), s.APIHandler(compat.StopContainer)).Methods(http.MethodPost) - // swagger:operation POST /libpod/containers/{name}/attach libpod libpodAttachContainer + // swagger:operation POST /libpod/containers/{name}/attach libpod ContainerAttachLibpod // --- // tags: // - containers @@ -1330,7 +1330,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/attach"), s.APIHandler(compat.AttachContainer)).Methods(http.MethodPost) - // swagger:operation POST /libpod/containers/{name}/resize libpod libpodResizeContainer + // swagger:operation POST /libpod/containers/{name}/resize libpod ContainerResizeLibpod // --- // tags: // - containers @@ -1362,7 +1362,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/resize"), s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) - // swagger:operation GET /libpod/containers/{name}/export libpod libpodExportContainer + // swagger:operation GET /libpod/containers/{name}/export libpod ContainerExportLibpod // --- // tags: // - containers @@ -1384,7 +1384,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/export"), s.APIHandler(compat.ExportContainer)).Methods(http.MethodGet) - // swagger:operation POST /libpod/containers/{name}/checkpoint libpod libpodCheckpointContainer + // swagger:operation POST /libpod/containers/{name}/checkpoint libpod ContainerCheckpointLibpod // --- // tags: // - containers @@ -1425,7 +1425,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/checkpoint"), s.APIHandler(libpod.Checkpoint)).Methods(http.MethodPost) - // swagger:operation POST /libpod/containers/{name}/restore libpod libpodRestoreContainer + // swagger:operation POST /libpod/containers/{name}/restore libpod ContainerRestoreLibpod // --- // tags: // - containers @@ -1479,8 +1479,8 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/restore"), s.APIHandler(libpod.Restore)).Methods(http.MethodPost) - // swagger:operation GET /containers/{name}/changes libpod ContainerChanges - // swagger:operation GET /libpod/containers/{name}/changes compat changesContainer + // swagger:operation GET /containers/{name}/changes libpod ContainerChangesLibpod + // swagger:operation GET /libpod/containers/{name}/changes compat ContainerChanges // --- // tags: // - containers @@ -1512,7 +1512,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/containers/{name}/changes"), s.APIHandler(compat.Changes)).Methods(http.MethodGet) r.HandleFunc("/containers/{name}/changes", s.APIHandler(compat.Changes)).Methods(http.MethodGet) r.HandleFunc(VersionedPath("/libpod/containers/{name}/changes"), s.APIHandler(compat.Changes)).Methods(http.MethodGet) - // swagger:operation POST /libpod/containers/{name}/init libpod libpodInitContainer + // swagger:operation POST /libpod/containers/{name}/init libpod ContainerInitLibpod // --- // tags: // - containers @@ -1536,7 +1536,7 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/containers/{name}/init"), s.APIHandler(libpod.InitContainer)).Methods(http.MethodPost) - // swagger:operation POST /libpod/containers/{name}/rename libpod libpodRenameContainer + // swagger:operation POST /libpod/containers/{name}/rename libpod ContainerRenameLibpod // --- // tags: // - containers diff --git a/pkg/api/server/register_events.go b/pkg/api/server/register_events.go index 01fc98377..553f2c0ea 100644 --- a/pkg/api/server/register_events.go +++ b/pkg/api/server/register_events.go @@ -37,7 +37,7 @@ func (s *APIServer) registerEventsHandlers(r *mux.Router) error { r.Handle(VersionedPath("/events"), s.APIHandler(compat.GetEvents)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/events", s.APIHandler(compat.GetEvents)).Methods(http.MethodGet) - // swagger:operation GET /libpod/events system libpodGetEvents + // swagger:operation GET /libpod/events system SystemEventsLibpod // --- // tags: // - system diff --git a/pkg/api/server/register_exec.go b/pkg/api/server/register_exec.go index 715bdde10..3716ef6a2 100644 --- a/pkg/api/server/register_exec.go +++ b/pkg/api/server/register_exec.go @@ -102,7 +102,7 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // type: boolean // description: Allocate a pseudo-TTY. Presently ignored. // produces: - // - application/json + // - application/octet-stream // responses: // 200: // description: no error @@ -182,7 +182,7 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { libpod api follows */ - // swagger:operation POST /libpod/containers/{name}/exec libpod libpodCreateExec + // swagger:operation POST /libpod/containers/{name}/exec libpod ContainerExecLibpod // --- // tags: // - exec @@ -249,7 +249,7 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/containers/{name}/exec"), s.APIHandler(compat.ExecCreateHandler)).Methods(http.MethodPost) - // swagger:operation POST /libpod/exec/{id}/start libpod libpodStartExec + // swagger:operation POST /libpod/exec/{id}/start libpod ExecStartLibpod // --- // tags: // - exec @@ -285,7 +285,7 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/exec/{id}/start"), s.APIHandler(compat.ExecStartHandler)).Methods(http.MethodPost) - // swagger:operation POST /libpod/exec/{id}/resize libpod libpodResizeExec + // swagger:operation POST /libpod/exec/{id}/resize libpod ExecResizeLibpod // --- // tags: // - exec @@ -316,7 +316,7 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/exec/{id}/resize"), s.APIHandler(compat.ResizeTTY)).Methods(http.MethodPost) - // swagger:operation GET /libpod/exec/{id}/json libpod libpodInspectExec + // swagger:operation GET /libpod/exec/{id}/json libpod ExecInspectLibpod // --- // tags: // - exec diff --git a/pkg/api/server/register_generate.go b/pkg/api/server/register_generate.go index abbad1485..208bf668c 100644 --- a/pkg/api/server/register_generate.go +++ b/pkg/api/server/register_generate.go @@ -8,7 +8,7 @@ import ( ) func (s *APIServer) registerGenerateHandlers(r *mux.Router) error { - // swagger:operation GET /libpod/generate/{name:.*}/systemd libpod libpodGenerateSystemd + // swagger:operation GET /libpod/generate/{name:.*}/systemd libpod GenerateSystemdLibpod // --- // tags: // - containers @@ -75,7 +75,7 @@ func (s *APIServer) registerGenerateHandlers(r *mux.Router) error { // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/generate/{name:.*}/systemd"), s.APIHandler(libpod.GenerateSystemd)).Methods(http.MethodGet) - // swagger:operation GET /libpod/generate/kube libpod libpodGenerateKube + // swagger:operation GET /libpod/generate/kube libpod GenerateKubeLibpod // --- // tags: // - containers diff --git a/pkg/api/server/register_healthcheck.go b/pkg/api/server/register_healthcheck.go index 85f3d720c..e2fd5ac68 100644 --- a/pkg/api/server/register_healthcheck.go +++ b/pkg/api/server/register_healthcheck.go @@ -8,7 +8,7 @@ import ( ) func (s *APIServer) registerHealthCheckHandlers(r *mux.Router) error { - // swagger:operation GET /libpod/containers/{name:.*}/healthcheck libpod libpodRunHealthCheck + // swagger:operation GET /libpod/containers/{name:.*}/healthcheck libpod ContainerHealthcheckLibpod // --- // tags: // - containers diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index b0423d200..de8d50cc9 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -19,6 +19,9 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // - images (compat) // summary: Create an image // description: Create an image by either pulling it from a registry or importing it. + // consumes: + // - text/plain + // - application/octet-stream // produces: // - application/json // parameters: @@ -279,7 +282,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // required: true // description: the name or ID of the container // produces: - // - application/json + // - application/x-tar // responses: // 200: // description: no error @@ -664,7 +667,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { libpod endpoints */ - // swagger:operation POST /libpod/images/{name:.*}/push libpod libpodPushImage + // swagger:operation POST /libpod/images/{name:.*}/push libpod ImagePushLibpod // --- // tags: // - images @@ -702,7 +705,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/push"), s.APIHandler(libpod.PushImage)).Methods(http.MethodPost) - // swagger:operation GET /libpod/images/{name:.*}/exists libpod libpodImageExists + // swagger:operation GET /libpod/images/{name:.*}/exists libpod ImageExistsLibpod // --- // tags: // - images @@ -724,7 +727,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/exists"), s.APIHandler(libpod.ImageExists)).Methods(http.MethodGet) - // swagger:operation GET /libpod/images/{name:.*}/tree libpod libpodImageTree + // swagger:operation GET /libpod/images/{name:.*}/tree libpod ImageTreeLibpod // --- // tags: // - images @@ -750,7 +753,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/tree"), s.APIHandler(libpod.ImageTree)).Methods(http.MethodGet) - // swagger:operation GET /libpod/images/{name:.*}/history libpod libpodImageHistory + // swagger:operation GET /libpod/images/{name:.*}/history libpod ImageHistoryLibpod // --- // tags: // - images @@ -772,7 +775,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/history"), s.APIHandler(compat.HistoryImage)).Methods(http.MethodGet) - // swagger:operation GET /libpod/images/json libpod libpodListImages + // swagger:operation GET /libpod/images/json libpod ImageListLibpod // --- // tags: // - images @@ -803,7 +806,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/json"), s.APIHandler(libpod.GetImages)).Methods(http.MethodGet) - // swagger:operation POST /libpod/images/load libpod libpodImagesLoad + // swagger:operation POST /libpod/images/load libpod ImageLoadLibpod // --- // tags: // - images @@ -828,7 +831,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/load"), s.APIHandler(libpod.ImagesLoad)).Methods(http.MethodPost) - // swagger:operation POST /libpod/images/import libpod libpodImagesImport + // swagger:operation POST /libpod/images/import libpod ImageImportLibpod // --- // tags: // - images @@ -871,7 +874,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/import"), s.APIHandler(libpod.ImagesImport)).Methods(http.MethodPost) - // swagger:operation DELETE /libpod/images/remove libpod libpodImagesRemove + // swagger:operation DELETE /libpod/images/remove libpod ImageDeleteAllLibpod // --- // tags: // - images @@ -903,7 +906,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/remove"), s.APIHandler(libpod.ImagesBatchRemove)).Methods(http.MethodDelete) - // swagger:operation DELETE /libpod/images/{name:.*} libpod libpodRemoveImage + // swagger:operation DELETE /libpod/images/{name:.*} libpod ImageDeleteLibpod // --- // tags: // - images @@ -933,7 +936,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/{name:.*}"), s.APIHandler(libpod.ImagesRemove)).Methods(http.MethodDelete) - // swagger:operation POST /libpod/images/pull libpod libpodImagesPull + // swagger:operation POST /libpod/images/pull libpod ImagePullLibpod // --- // tags: // - images @@ -979,7 +982,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/pull"), s.APIHandler(libpod.ImagesPull)).Methods(http.MethodPost) - // swagger:operation POST /libpod/images/prune libpod libpodPruneImages + // swagger:operation POST /libpod/images/prune libpod ImagePruneLibpod // --- // tags: // - images @@ -1004,7 +1007,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/prune"), s.APIHandler(libpod.PruneImages)).Methods(http.MethodPost) - // swagger:operation GET /libpod/images/search libpod libpodSearchImages + // swagger:operation GET /libpod/images/search libpod ImageSearchLibpod // --- // tags: // - images @@ -1039,7 +1042,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/search"), s.APIHandler(compat.SearchImages)).Methods(http.MethodGet) - // swagger:operation GET /libpod/images/{name:.*}/get libpod libpodExportImage + // swagger:operation GET /libpod/images/{name:.*}/get libpod ImageGetLibpod // --- // tags: // - images @@ -1060,7 +1063,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // type: boolean // description: use compression on image // produces: - // - application/json + // - application/x-tar // responses: // 200: // description: no error @@ -1072,7 +1075,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/get"), s.APIHandler(libpod.ExportImage)).Methods(http.MethodGet) - // swagger:operation GET /libpod/images/export libpod libpodExportImages + // swagger:operation GET /libpod/images/export libpod ImageExportLibpod // --- // tags: // - images @@ -1106,7 +1109,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/export"), s.APIHandler(libpod.ExportImages)).Methods(http.MethodGet) - // swagger:operation GET /libpod/images/{name:.*}/json libpod libpodInspectImage + // swagger:operation GET /libpod/images/{name:.*}/json libpod ImageInspectLibpod // --- // tags: // - images @@ -1128,7 +1131,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/json"), s.APIHandler(libpod.GetImage)).Methods(http.MethodGet) - // swagger:operation POST /libpod/images/{name:.*}/tag libpod libpodTagImage + // swagger:operation POST /libpod/images/{name:.*}/tag libpod ImageTagLibpod // --- // tags: // - images @@ -1162,7 +1165,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/tag"), s.APIHandler(compat.TagImage)).Methods(http.MethodPost) - // swagger:operation POST /libpod/commit libpod libpodCommitContainer + // swagger:operation POST /libpod/commit libpod ImageCommitLibpod // --- // tags: // - containers @@ -1214,7 +1217,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/commit"), s.APIHandler(libpod.CommitContainer)).Methods(http.MethodPost) - // swagger:operation POST /libpod/images/{name:.*}/untag libpod libpodUntagImage + // swagger:operation POST /libpod/images/{name:.*}/untag libpod ImageUntagLibpod // --- // tags: // - images @@ -1249,7 +1252,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/images/{name:.*}/untag"), s.APIHandler(libpod.UntagImage)).Methods(http.MethodPost) - // swagger:operation GET /libpod/images/{name}/changes libpod libpodChangesImages + // swagger:operation GET /libpod/images/{name}/changes libpod ImageChangesLibpod // --- // tags: // - images @@ -1279,7 +1282,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/images/{name}/changes"), s.APIHandler(compat.Changes)).Methods(http.MethodGet) - // swagger:operation POST /libpod/build libpod libpodBuildImage + // swagger:operation POST /libpod/build libpod ImageBuildLibpod // --- // tags: // - images diff --git a/pkg/api/server/register_info.go b/pkg/api/server/register_info.go index ba4f3719c..45185ba3b 100644 --- a/pkg/api/server/register_info.go +++ b/pkg/api/server/register_info.go @@ -25,7 +25,7 @@ func (s *APIServer) registerInfoHandlers(r *mux.Router) error { r.Handle(VersionedPath("/info"), s.APIHandler(compat.GetInfo)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/info", s.APIHandler(compat.GetInfo)).Methods(http.MethodGet) - // swagger:operation GET /libpod/info libpod libpodGetInfo + // swagger:operation GET /libpod/info libpod SystemInfoLibpod // --- // tags: // - system diff --git a/pkg/api/server/register_manifest.go b/pkg/api/server/register_manifest.go index adb545b51..ba5577a85 100644 --- a/pkg/api/server/register_manifest.go +++ b/pkg/api/server/register_manifest.go @@ -8,7 +8,7 @@ import ( ) func (s *APIServer) registerManifestHandlers(r *mux.Router) error { - // swagger:operation POST /libpod/manifests/create manifests Create + // swagger:operation POST /libpod/manifests/create manifests ManifestCreateLibpod // --- // summary: Create // description: Create a manifest list @@ -39,7 +39,7 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/manifests/create"), s.APIHandler(libpod.ManifestCreate)).Methods(http.MethodPost) - // swagger:operation GET /libpod/manifests/{name}/exists manifests Exists + // swagger:operation GET /libpod/manifests/{name}/exists manifests ManifestExistsLibpod // --- // summary: Exists // description: Check if manifest list exists @@ -59,7 +59,7 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/manifests/{name}/exists"), s.APIHandler(libpod.ExistsManifest)).Methods(http.MethodGet) - // swagger:operation GET /libpod/manifests/{name:.*}/json manifests Inspect + // swagger:operation GET /libpod/manifests/{name:.*}/json manifests ManifestInspectLibpod // --- // summary: Inspect // description: Display a manifest list @@ -79,7 +79,7 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/manifests/{name:.*}/json"), s.APIHandler(libpod.ManifestInspect)).Methods(http.MethodGet) - // swagger:operation POST /libpod/manifests/{name:.*}/add manifests AddManifest + // swagger:operation POST /libpod/manifests/{name:.*}/add manifests ManifestAddLibpod // --- // summary: Add image // description: Add an image to a manifest list @@ -107,7 +107,7 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/manifests/{name:.*}/add"), s.APIHandler(libpod.ManifestAdd)).Methods(http.MethodPost) - // swagger:operation DELETE /libpod/manifests/{name:.*} manifests RemoveManifest + // swagger:operation DELETE /libpod/manifests/{name:.*} manifests ManifestDeleteLibpod // --- // summary: Remove // description: Remove an image from a manifest list @@ -134,7 +134,7 @@ func (s *APIServer) registerManifestHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/manifests/{name:.*}"), s.APIHandler(libpod.ManifestRemove)).Methods(http.MethodDelete) - // swagger:operation POST /libpod/manifests/{name}/push manifests PushManifest + // swagger:operation POST /libpod/manifests/{name}/push manifests ManifestPushLibpod // --- // summary: Push // description: Push a manifest list or image index to a registry diff --git a/pkg/api/server/register_networks.go b/pkg/api/server/register_networks.go index 48456f3d6..dcec61bef 100644 --- a/pkg/api/server/register_networks.go +++ b/pkg/api/server/register_networks.go @@ -9,19 +9,6 @@ import ( ) func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { - // swagger:operation POST /networks/prune compat NetworkPrune - // --- - // tags: - // - networks (compat) - // Summary: Delete unused networks - // description: Not supported - // produces: - // - application/json - // responses: - // 404: - // $ref: "#/responses/NoSuchNetwork" - r.HandleFunc(VersionedPath("/networks/prune"), compat.UnsupportedHandler).Methods(http.MethodPost) - r.HandleFunc("/networks/prune", compat.UnsupportedHandler).Methods(http.MethodPost) // swagger:operation DELETE /networks/{name} compat NetworkDelete // --- // tags: @@ -172,7 +159,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/networks/{name}/disconnect"), s.APIHandler(compat.Disconnect)).Methods(http.MethodPost) r.HandleFunc("/networks/{name}/disconnect", s.APIHandler(compat.Disconnect)).Methods(http.MethodPost) - // swagger:operation POST /networks/prune compat compatPruneNetwork + // swagger:operation POST /networks/prune compat NetworkPrune // --- // tags: // - networks (compat) @@ -201,7 +188,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { r.HandleFunc(VersionedPath("/networks/prune"), s.APIHandler(compat.Prune)).Methods(http.MethodPost) r.HandleFunc("/networks/prune", s.APIHandler(compat.Prune)).Methods(http.MethodPost) - // swagger:operation DELETE /libpod/networks/{name} libpod libpodRemoveNetwork + // swagger:operation DELETE /libpod/networks/{name} libpod NetworkDeleteLibpod // --- // tags: // - networks @@ -226,35 +213,8 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // $ref: "#/responses/NoSuchNetwork" // 500: // $ref: "#/responses/InternalError" - - /* - Libpod - */ - r.HandleFunc(VersionedPath("/libpod/networks/{name}"), s.APIHandler(libpod.RemoveNetwork)).Methods(http.MethodDelete) - // swagger:operation GET /libpod/networks/{name}/json libpod libpodInspectNetwork - // --- - // tags: - // - networks - // summary: Inspect a network - // description: Display low level configuration for a CNI network - // parameters: - // - in: path - // name: name - // type: string - // required: true - // description: the name of the network - // produces: - // - application/json - // responses: - // 200: - // $ref: "#/responses/NetworkInspectReport" - // 404: - // $ref: "#/responses/NoSuchNetwork" - // 500: - // $ref: "#/responses/InternalError" - r.HandleFunc(VersionedPath("/libpod/networks/{name}/json"), s.APIHandler(libpod.InspectNetwork)).Methods(http.MethodGet) - // swagger:operation GET /libpod/networks/{name}/exists libpod libpodExistsNetwork + // swagger:operation GET /libpod/networks/{name}/exists libpod NetworkExistsLibpod // --- // tags: // - networks @@ -276,7 +236,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/networks/{name}/exists"), s.APIHandler(libpod.ExistsNetwork)).Methods(http.MethodGet) - // swagger:operation GET /libpod/networks/json libpod libpodListNetwork + // swagger:operation GET /libpod/networks/json libpod NetworkListLibpod // --- // tags: // - networks @@ -301,7 +261,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/networks/json"), s.APIHandler(libpod.ListNetworks)).Methods(http.MethodGet) - // swagger:operation GET /libpod/networks/{name}/json libpod libpodInspectNetwork + // swagger:operation GET /libpod/networks/{name}/json libpod NetworkInspectLibpod // --- // tags: // - networks @@ -324,7 +284,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/networks/{name}/json"), s.APIHandler(libpod.InspectNetwork)).Methods(http.MethodGet) r.HandleFunc(VersionedPath("/libpod/networks/{name}"), s.APIHandler(libpod.InspectNetwork)).Methods(http.MethodGet) - // swagger:operation POST /libpod/networks/create libpod libpodCreateNetwork + // swagger:operation POST /libpod/networks/create libpod NetworkCreateLibpod // --- // tags: // - networks @@ -350,7 +310,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/networks/create"), s.APIHandler(libpod.CreateNetwork)).Methods(http.MethodPost) - // swagger:operation POST /libpod/networks/{name}/connect libpod libpodConnectNetwork + // swagger:operation POST /libpod/networks/{name}/connect libpod NetworkConnectLibpod // --- // tags: // - networks @@ -377,7 +337,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/networks/{name}/connect"), s.APIHandler(libpod.Connect)).Methods(http.MethodPost) - // swagger:operation POST /libpod/networks/{name}/disconnect libpod libpodDisconnectNetwork + // swagger:operation POST /libpod/networks/{name}/disconnect libpod NetworkDisconnectLibpod // --- // tags: // - networks @@ -404,7 +364,7 @@ func (s *APIServer) registerNetworkHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.HandleFunc(VersionedPath("/libpod/networks/{name}/disconnect"), s.APIHandler(compat.Disconnect)).Methods(http.MethodPost) - // swagger:operation POST /libpod/networks/prune libpod libpodPruneNetwork + // swagger:operation POST /libpod/networks/prune libpod NetworkPruneLibpod // --- // tags: // - networks diff --git a/pkg/api/server/register_ping.go b/pkg/api/server/register_ping.go index 1d0876ec1..1222b3dba 100644 --- a/pkg/api/server/register_ping.go +++ b/pkg/api/server/register_ping.go @@ -10,7 +10,7 @@ import ( func (s *APIServer) registerPingHandlers(r *mux.Router) error { r.Handle("/_ping", s.APIHandler(compat.Ping)).Methods(http.MethodGet, http.MethodHead) r.Handle(VersionedPath("/_ping"), s.APIHandler(compat.Ping)).Methods(http.MethodGet, http.MethodHead) - // swagger:operation GET /libpod/_ping libpod libpodPingGet + // swagger:operation GET /libpod/_ping libpod SystemPing // --- // summary: Ping service // description: | diff --git a/pkg/api/server/register_play.go b/pkg/api/server/register_play.go index dbb13cba3..b9d3349be 100644 --- a/pkg/api/server/register_play.go +++ b/pkg/api/server/register_play.go @@ -8,7 +8,7 @@ import ( ) func (s *APIServer) registerPlayHandlers(r *mux.Router) error { - // swagger:operation POST /libpod/play/kube libpod libpodPlayKube + // swagger:operation POST /libpod/play/kube libpod KubePlayLibpod // --- // tags: // - containers diff --git a/pkg/api/server/register_pods.go b/pkg/api/server/register_pods.go index d0887aada..23fdd6fb0 100644 --- a/pkg/api/server/register_pods.go +++ b/pkg/api/server/register_pods.go @@ -8,7 +8,7 @@ import ( ) func (s *APIServer) registerPodsHandlers(r *mux.Router) error { - // swagger:operation GET /libpod/pods/json pods ListPods + // swagger:operation GET /libpod/pods/json pods PodListLibpod // --- // summary: List pods // produces: @@ -26,7 +26,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/json"), s.APIHandler(libpod.Pods)).Methods(http.MethodGet) - // swagger:operation POST /libpod/pods/create pods CreatePod + // swagger:operation POST /libpod/pods/create pods PodCreateLibpod // --- // summary: Create a pod // produces: @@ -51,7 +51,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/create"), s.APIHandler(libpod.PodCreate)).Methods(http.MethodPost) - // swagger:operation POST /libpod/pods/prune pods PrunePods + // swagger:operation POST /libpod/pods/prune pods PodPruneLibpod // --- // summary: Prune unused pods // produces: @@ -66,7 +66,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/prune"), s.APIHandler(libpod.PodPrune)).Methods(http.MethodPost) - // swagger:operation DELETE /libpod/pods/{name} pods removePod + // swagger:operation DELETE /libpod/pods/{name} pods PodDeleteLibpod // --- // summary: Remove pod // produces: @@ -91,7 +91,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/{name}"), s.APIHandler(libpod.PodDelete)).Methods(http.MethodDelete) - // swagger:operation GET /libpod/pods/{name}/json pods inspectPod + // swagger:operation GET /libpod/pods/{name}/json pods PodInspectLibpod // --- // summary: Inspect pod // produces: @@ -110,7 +110,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/{name}/json"), s.APIHandler(libpod.PodInspect)).Methods(http.MethodGet) - // swagger:operation GET /libpod/pods/{name}/exists pods podExists + // swagger:operation GET /libpod/pods/{name}/exists pods PodExistsLibpod // --- // summary: Pod exists // description: Check if a pod exists by name or ID @@ -130,7 +130,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/{name}/exists"), s.APIHandler(libpod.PodExists)).Methods(http.MethodGet) - // swagger:operation POST /libpod/pods/{name}/kill pods killPod + // swagger:operation POST /libpod/pods/{name}/kill pods PodKillLibpod // --- // summary: Kill a pod // produces: @@ -158,7 +158,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/{name}/kill"), s.APIHandler(libpod.PodKill)).Methods(http.MethodPost) - // swagger:operation POST /libpod/pods/{name}/pause pods pausePod + // swagger:operation POST /libpod/pods/{name}/pause pods PodPauseLibpod // --- // summary: Pause a pod // description: Pause a pod @@ -180,7 +180,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/{name}/pause"), s.APIHandler(libpod.PodPause)).Methods(http.MethodPost) - // swagger:operation POST /libpod/pods/{name}/restart pods restartPod + // swagger:operation POST /libpod/pods/{name}/restart pods PodRestartLibpod // --- // summary: Restart a pod // produces: @@ -201,7 +201,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/{name}/restart"), s.APIHandler(libpod.PodRestart)).Methods(http.MethodPost) - // swagger:operation POST /libpod/pods/{name}/start pods startPod + // swagger:operation POST /libpod/pods/{name}/start pods PodStartLibpod // --- // summary: Start a pod // produces: @@ -224,7 +224,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/{name}/start"), s.APIHandler(libpod.PodStart)).Methods(http.MethodPost) - // swagger:operation POST /libpod/pods/{name}/stop pods stopPod + // swagger:operation POST /libpod/pods/{name}/stop pods PodStopLibpod // --- // summary: Stop a pod // produces: @@ -253,7 +253,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/{name}/stop"), s.APIHandler(libpod.PodStop)).Methods(http.MethodPost) - // swagger:operation POST /libpod/pods/{name}/unpause pods unpausePod + // swagger:operation POST /libpod/pods/{name}/unpause pods PodUnpauseLibpod // --- // summary: Unpause a pod // produces: @@ -274,7 +274,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/{name}/unpause"), s.APIHandler(libpod.PodUnpause)).Methods(http.MethodPost) - // swagger:operation GET /libpod/pods/{name}/top pods topPod + // swagger:operation GET /libpod/pods/{name}/top pods PodTopLibpod // --- // summary: List processes // description: List processes running inside a pod @@ -305,7 +305,7 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/pods/{name}/top"), s.APIHandler(libpod.PodTop)).Methods(http.MethodGet) - // swagger:operation GET /libpod/pods/stats pods statsPod + // swagger:operation GET /libpod/pods/stats pods PodStatsLibpod // --- // tags: // - pods diff --git a/pkg/api/server/register_secrets.go b/pkg/api/server/register_secrets.go index 531623845..ca9790e93 100644 --- a/pkg/api/server/register_secrets.go +++ b/pkg/api/server/register_secrets.go @@ -9,7 +9,7 @@ import ( ) func (s *APIServer) registerSecretHandlers(r *mux.Router) error { - // swagger:operation POST /libpod/secrets/create libpod libpodCreateSecret + // swagger:operation POST /libpod/secrets/create libpod SecretCreateLibpod // --- // tags: // - secrets @@ -38,7 +38,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // '500': // "$ref": "#/responses/InternalError" r.Handle(VersionedPath("/libpod/secrets/create"), s.APIHandler(libpod.CreateSecret)).Methods(http.MethodPost) - // swagger:operation GET /libpod/secrets/json libpod libpodListSecret + // swagger:operation GET /libpod/secrets/json libpod SecretListLibpod // --- // tags: // - secrets @@ -53,7 +53,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // '500': // "$ref": "#/responses/InternalError" r.Handle(VersionedPath("/libpod/secrets/json"), s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet) - // swagger:operation GET /libpod/secrets/{name}/json libpod libpodInspectSecret + // swagger:operation GET /libpod/secrets/{name}/json libpod SecretInspectLibpod // --- // tags: // - secrets @@ -74,7 +74,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // '500': // "$ref": "#/responses/InternalError" r.Handle(VersionedPath("/libpod/secrets/{name}/json"), s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet) - // swagger:operation DELETE /libpod/secrets/{name} libpod libpodRemoveSecret + // swagger:operation DELETE /libpod/secrets/{name} libpod SecretDeleteLibpod // --- // tags: // - secrets @@ -104,7 +104,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { /* * Docker compatibility endpoints */ - // swagger:operation GET /secrets compat ListSecret + // swagger:operation GET /secrets compat SecretList // --- // tags: // - secrets (compat) @@ -120,7 +120,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // "$ref": "#/responses/InternalError" r.Handle(VersionedPath("/secrets"), s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet) r.Handle("/secrets", s.APIHandler(compat.ListSecrets)).Methods(http.MethodGet) - // swagger:operation POST /secrets/create compat CreateSecret + // swagger:operation POST /secrets/create compat SecretCreate // --- // tags: // - secrets (compat) @@ -143,7 +143,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // "$ref": "#/responses/InternalError" r.Handle(VersionedPath("/secrets/create"), s.APIHandler(compat.CreateSecret)).Methods(http.MethodPost) r.Handle("/secrets/create", s.APIHandler(compat.CreateSecret)).Methods(http.MethodPost) - // swagger:operation GET /secrets/{name} compat InspectSecret + // swagger:operation GET /secrets/{name} compat SecretInspect // --- // tags: // - secrets (compat) @@ -165,7 +165,7 @@ func (s *APIServer) registerSecretHandlers(r *mux.Router) error { // "$ref": "#/responses/InternalError" r.Handle(VersionedPath("/secrets/{name}"), s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet) r.Handle("/secrets/{name}", s.APIHandler(compat.InspectSecret)).Methods(http.MethodGet) - // swagger:operation DELETE /secrets/{name} compat RemoveSecret + // swagger:operation DELETE /secrets/{name} compat SecretDelete // --- // tags: // - secrets (compat) diff --git a/pkg/api/server/register_system.go b/pkg/api/server/register_system.go index 7bc16acc0..739daf7a6 100644 --- a/pkg/api/server/register_system.go +++ b/pkg/api/server/register_system.go @@ -9,10 +9,23 @@ import ( ) func (s *APIServer) registerSystemHandlers(r *mux.Router) error { + // swagger:operation GET /system/df compat SystemDataUsage + // --- + // tags: + // - system (compat) + // summary: Show disk usage + // description: Return information about disk usage for containers, images, and volumes + // produces: + // - application/json + // responses: + // 200: + // $ref: '#/responses/SystemDiskUse' + // 500: + // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/system/df"), s.APIHandler(compat.GetDiskUsage)).Methods(http.MethodGet) // Added non version path to URI to support docker non versioned paths r.Handle("/system/df", s.APIHandler(compat.GetDiskUsage)).Methods(http.MethodGet) - // swagger:operation POST /libpod/system/prune libpod pruneSystem + // swagger:operation POST /libpod/system/prune libpod SystemPruneLibpod // --- // tags: // - system @@ -27,7 +40,7 @@ func (s *APIServer) registerSystemHandlers(r *mux.Router) error { // 500: // $ref: "#/responses/InternalError" r.Handle(VersionedPath("/libpod/system/prune"), s.APIHandler(libpod.SystemPrune)).Methods(http.MethodPost) - // swagger:operation GET /libpod/system/df libpod df + // swagger:operation GET /libpod/system/df libpod SystemDataUsageLibpod // --- // tags: // - system diff --git a/pkg/api/server/register_version.go b/pkg/api/server/register_version.go index 71600e30d..462edf4ee 100644 --- a/pkg/api/server/register_version.go +++ b/pkg/api/server/register_version.go @@ -20,7 +20,7 @@ func (s *APIServer) registerVersionHandlers(r *mux.Router) error { // $ref: "#/responses/Version" r.Handle("/version", s.APIHandler(compat.VersionHandler)).Methods(http.MethodGet) r.Handle(VersionedPath("/version"), s.APIHandler(compat.VersionHandler)).Methods(http.MethodGet) - // swagger:operation GET /libpod/version libpod SystemVersion + // swagger:operation GET /libpod/version libpod SystemVersionLibpod // --- // summary: Component Version information // tags: diff --git a/pkg/api/server/register_volumes.go b/pkg/api/server/register_volumes.go index f100587b9..e5d6cf195 100644 --- a/pkg/api/server/register_volumes.go +++ b/pkg/api/server/register_volumes.go @@ -9,7 +9,7 @@ import ( ) func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { - // swagger:operation POST /libpod/volumes/create libpod libpodCreateVolume + // swagger:operation POST /libpod/volumes/create libpod VolumeCreateLibpod // --- // tags: // - volumes @@ -28,7 +28,7 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // '500': // "$ref": "#/responses/InternalError" r.Handle(VersionedPath("/libpod/volumes/create"), s.APIHandler(libpod.CreateVolume)).Methods(http.MethodPost) - // swagger:operation GET /libpod/volumes/{name}/exists libpod libpodExistsVolume + // swagger:operation GET /libpod/volumes/{name}/exists libpod VolumeExistsLibpod // --- // tags: // - volumes @@ -50,7 +50,7 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // 500: // $ref: '#/responses/InternalError' r.Handle(VersionedPath("/libpod/volumes/{name}/exists"), s.APIHandler(libpod.ExistsVolume)).Methods(http.MethodGet) - // swagger:operation GET /libpod/volumes/json libpod libpodListVolumes + // swagger:operation GET /libpod/volumes/json libpod VolumeListLibpod // --- // tags: // - volumes @@ -74,7 +74,7 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // '500': // "$ref": "#/responses/InternalError" r.Handle(VersionedPath("/libpod/volumes/json"), s.APIHandler(libpod.ListVolumes)).Methods(http.MethodGet) - // swagger:operation POST /libpod/volumes/prune libpod libpodPruneVolumes + // swagger:operation POST /libpod/volumes/prune libpod VolumePruneLibpod // --- // tags: // - volumes @@ -95,7 +95,7 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // '500': // "$ref": "#/responses/InternalError" r.Handle(VersionedPath("/libpod/volumes/prune"), s.APIHandler(libpod.PruneVolumes)).Methods(http.MethodPost) - // swagger:operation GET /libpod/volumes/{name}/json libpod libpodInspectVolume + // swagger:operation GET /libpod/volumes/{name}/json libpod VolumeInspectLibpod // --- // tags: // - volumes @@ -116,7 +116,7 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error { // '500': // "$ref": "#/responses/InternalError" r.Handle(VersionedPath("/libpod/volumes/{name}/json"), s.APIHandler(libpod.InspectVolume)).Methods(http.MethodGet) - // swagger:operation DELETE /libpod/volumes/{name} libpod libpodRemoveVolume + // swagger:operation DELETE /libpod/volumes/{name} libpod VolumeDeleteLibpod // --- // tags: // - volumes diff --git a/pkg/api/tags.yaml b/pkg/api/tags.yaml index bb56098eb..ae29c39a6 100644 --- a/pkg/api/tags.yaml +++ b/pkg/api/tags.yaml @@ -24,7 +24,7 @@ tags: - name: images (compat) description: Actions related to images for the compatibility endpoints - name: networks (compat) - description: Actions related to compatibility networks + description: Actions related to networks for the compatibility endpoints - name: volumes (compat) description: Actions related to volumes for the compatibility endpoints - name: secrets (compat) -- cgit v1.2.3-54-g00ecf From e4c811bb0f629a2d8718cd82b674dedeaecc31a2 Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Thu, 15 Apr 2021 14:24:13 -0400 Subject: Fix build with GO111MODULE=off Distro builds on Fedora and Kubic projects use GO111MODULE=off by default which are currently failing. This commit fixes it and going forward, podman CI will also indicate failures in rpm builds. The additional LDFLAGS have been removed from the spec file which is not ideal. But, currently we only use the spec file to check if the rpm builds fine. We can fix the LDFLAGS in a later commit when we're working on packit integration. conmon build has also been removed from podman.spec.in because the COPR for which it was provided has been discontinued. [NO TESTS NEEDED] Fixes: #10009 Signed-off-by: Lokesh Mandvekar --- contrib/spec/podman.spec.in | 64 ++++++++++++++++++++++---------------- pkg/domain/entities/types/auth.go | 3 +- pkg/domain/entities/types/types.go | 3 +- 3 files changed, 41 insertions(+), 29 deletions(-) (limited to 'pkg') diff --git a/contrib/spec/podman.spec.in b/contrib/spec/podman.spec.in index 9d871f719..086bbdb24 100644 --- a/contrib/spec/podman.spec.in +++ b/contrib/spec/podman.spec.in @@ -12,9 +12,9 @@ %global debug_package %{nil} %endif -# %if ! 0% {?gobuild:1} -%define gobuild(o:) go build -tags="$BUILDTAGS" -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**}; -#% endif +%if ! 0%{?gobuild:1} +%define gobuild(o:) go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -extldflags '-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '" -a -v -x %{?**}; +%endif # podman hack directory %define hackdir %{_builddir}/%{repo}-%{shortcommit0} @@ -30,12 +30,6 @@ %global commit0 #COMMIT# %global shortcommit0 %(c=%{commit0}; echo ${c:0:8}) -# People want conmon packaged with the copr rpm -%global import_path_conmon github.com/containers/conmon -%global git_conmon https://%{import_path_conmon} -%global commit_conmon 41877362fc4685d55e0473d2e4a1cbe5e1debee0 -%global shortcommit_conmon %(c=%{commit_conmon}; echo ${c:0:7}) - Name: podman %if 0%{?fedora} Epoch: 99 @@ -74,7 +68,8 @@ BuildRequires: libselinux-devel BuildRequires: pkgconfig BuildRequires: make BuildRequires: systemd-devel -Requires: skopeo-containers +Requires: containers-common +Requires: conmon Requires: containernetworking-plugins >= 0.6.0-3 Requires: iptables %if 0%{?rhel} < 8 || 0%{?centos} < 8 @@ -371,6 +366,26 @@ BuildArch: noarch Man pages for the %{name} commands %endif +%if 0%{?fedora} && ! 0%{?centos} +%package tests +Summary: Tests for %{name} + +Requires: %{name} = %{epoch}:%{version}-%{release} +Requires: bats +Requires: jq +Requires: skopeo +Requires: nmap-ncat +Requires: httpd-tools +Requires: openssl +Requires: socat +Requires: buildah + +%description tests +%{summary} + +This package contains system tests for %{name} +%endif + %prep %autosetup -Sgit -n %{repo}-%{shortcommit0} @@ -416,18 +431,6 @@ BUILDTAGS=$BUILDTAGS make binaries docs %else BUILDTAGS=$BUILDTAGS make binaries %endif -# build conmon -pushd conmon - -mkdir _output -pushd _output -mkdir -p src/%{provider}.%{provider_tld}/{containers,opencontainers} -ln -s $(dirs +1 -l) src/%{import_path_conmon} -popd - -export BUILDTAGS="selinux seccomp systemd $(%{hackdir}/hack/btrfs_installed_tag.sh) $(%{hackdir}/hack/btrfs_tag.sh)" -BUILDTAGS=$BUILDTAGS make -popd %install install -dp %{buildroot}%{_unitdir} @@ -444,10 +447,6 @@ PODMAN_VERSION=%{version} %{__make} PREFIX=%{buildroot}%{_prefix} ETCDIR=%{build mv pkg/hooks/README.md pkg/hooks/README-hooks.md -# install conmon -install -dp %{buildroot}%{_libexecdir}/%{name} -install -p -m 755 conmon/bin/conmon %{buildroot}%{_libexecdir}/%{name} - # source codes for building projects %if 0%{?with_devel} install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ @@ -467,6 +466,11 @@ for file in $(find . \( -iname "*.go" -or -iname "*.s" \) \! -iname "*_test.go" done %endif +%if 0%{?fedora} && ! 0%{?centos} +install -d -p %{buildroot}/%{_datadir}/%{name}/test/system +cp -pav test/system %{buildroot}/%{_datadir}/%{name}/test/ +%endif + # testing files for this project %if 0%{?with_unit_test} && 0%{?with_devel} install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ @@ -522,7 +526,6 @@ export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath} %{_datadir}/bash-completion/completions/* %{_datadir}/zsh/site-functions/* %{_datadir}/fish/vendor_completions.d/* -%{_libexecdir}/%{name}/conmon %config(noreplace) %{_sysconfdir}/cni/net.d/87-%{name}-bridge.conflist %{_unitdir}/podman-auto-update.service %{_unitdir}/podman-auto-update.timer @@ -558,6 +561,13 @@ export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath} %{_mandir}/man5/*.5* %endif +%if 0%{?fedora} && ! 0%{?centos} +%files tests +%license LICENSE +%{_datadir}/%{name}/test +%dir %{_datadir}/%{name}/test/system +%endif + %changelog * Sat Aug 4 2018 Dan Walsh - 0.8.1-1.git6b4ab2a - Bump to v0.8.1 diff --git a/pkg/domain/entities/types/auth.go b/pkg/domain/entities/types/auth.go index ddf15bb18..7f2480173 100644 --- a/pkg/domain/entities/types/auth.go +++ b/pkg/domain/entities/types/auth.go @@ -1,4 +1,5 @@ -package types // import "github.com/docker/docker/api/types" +// copied from github.com/docker/docker/api/types +package types // AuthConfig contains authorization information for connecting to a Registry type AuthConfig struct { diff --git a/pkg/domain/entities/types/types.go b/pkg/domain/entities/types/types.go index 77834c0cb..7dc785078 100644 --- a/pkg/domain/entities/types/types.go +++ b/pkg/domain/entities/types/types.go @@ -1,4 +1,5 @@ -package types // import "github.com/docker/docker/api/types" +// copied from github.com/docker/docker/api/types +package types // ComponentVersion describes the version information for a specific component. type ComponentVersion struct { -- cgit v1.2.3-54-g00ecf From 9584a2a8a17ecffa974891d76b6d6482555e7b72 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 15 Apr 2021 18:24:22 +0200 Subject: podman play kube apply correct log driver The --log-driver flag was silently ignored by podman play kube. This regression got introduced during the play kube rework. Unfortunately the test for this was skipped for no good reason. Fixes #10015 Signed-off-by: Paul Holzinger Signed-off-by: Matthew Heon --- pkg/domain/infra/abi/play.go | 21 +++++++++++---------- pkg/specgen/generate/kube/kube.go | 6 ++++++ test/e2e/play_kube_test.go | 1 - 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'pkg') diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index 7d87fc83a..6e705ddd2 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -261,16 +261,17 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY } specgenOpts := kube.CtrSpecGenOptions{ - Container: container, - Image: newImage, - Volumes: volumes, - PodID: pod.ID(), - PodName: podName, - PodInfraID: podInfraID, - ConfigMaps: configMaps, - SeccompPaths: seccompPaths, - RestartPolicy: ctrRestartPolicy, - NetNSIsHost: p.NetNS.IsHost(), + Container: container, + Image: newImage, + Volumes: volumes, + PodID: pod.ID(), + PodName: podName, + PodInfraID: podInfraID, + ConfigMaps: configMaps, + SeccompPaths: seccompPaths, + RestartPolicy: ctrRestartPolicy, + NetNSIsHost: p.NetNS.IsHost(), + LogDriver: options.LogDriver, } specGen, err := kube.ToSpecGen(ctx, &specgenOpts) if err != nil { diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index d61c8bd19..45cb7c3f6 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -94,6 +94,8 @@ type CtrSpecGenOptions struct { RestartPolicy string // NetNSIsHost tells the container to use the host netns NetNSIsHost bool + // LogDriver which should be used for the container + LogDriver string } func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGenerator, error) { @@ -111,6 +113,10 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener s.Pod = opts.PodID + s.LogConfiguration = &specgen.LogConfig{ + Driver: opts.LogDriver, + } + setupSecurityContext(s, opts.Container) // Since we prefix the container name with pod name to work-around the uniqueness requirement, diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index a4c738f17..2a1ba86e5 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -1674,7 +1674,6 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`}) }) It("podman play kube applies log driver to containers", func() { - Skip("need to verify images have correct packages for journald") pod := getPod() err := generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) -- cgit v1.2.3-54-g00ecf From 9148568b2610c6d1fa03d90acf1f77f7bcea6ba4 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Fri, 16 Apr 2021 14:41:15 -0400 Subject: Fix lint Signed-off-by: Matthew Heon --- pkg/domain/infra/abi/play.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'pkg') diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index 6e705ddd2..382ec4a4b 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -261,17 +261,17 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY } specgenOpts := kube.CtrSpecGenOptions{ - Container: container, - Image: newImage, - Volumes: volumes, - PodID: pod.ID(), - PodName: podName, - PodInfraID: podInfraID, - ConfigMaps: configMaps, - SeccompPaths: seccompPaths, - RestartPolicy: ctrRestartPolicy, - NetNSIsHost: p.NetNS.IsHost(), - LogDriver: options.LogDriver, + Container: container, + Image: newImage, + Volumes: volumes, + PodID: pod.ID(), + PodName: podName, + PodInfraID: podInfraID, + ConfigMaps: configMaps, + SeccompPaths: seccompPaths, + RestartPolicy: ctrRestartPolicy, + NetNSIsHost: p.NetNS.IsHost(), + LogDriver: options.LogDriver, } specGen, err := kube.ToSpecGen(ctx, &specgenOpts) if err != nil { -- cgit v1.2.3-54-g00ecf