diff options
author | Brent Baude <bbaude@redhat.com> | 2020-03-15 11:53:59 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-04-06 12:45:42 -0500 |
commit | e20ecc733c878f0c4b67a21204f0d5ae11929bf0 (patch) | |
tree | 8686fd9c9f123cbed11f0589655caaa128b12061 /pkg/api/handlers/libpod | |
parent | e318b09b6800ddb013ddf3b9a2fb99ebc55bd920 (diff) | |
download | podman-e20ecc733c878f0c4b67a21204f0d5ae11929bf0.tar.gz podman-e20ecc733c878f0c4b67a21204f0d5ae11929bf0.tar.bz2 podman-e20ecc733c878f0c4b67a21204f0d5ae11929bf0.zip |
refactor info
the current implementation of info, while typed, is very loosely done so. we need stronger types for our apiv2 implmentation and bindings.
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/api/handlers/libpod')
-rw-r--r-- | pkg/api/handlers/libpod/info.go | 18 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/swagger.go | 8 |
2 files changed, 26 insertions, 0 deletions
diff --git a/pkg/api/handlers/libpod/info.go b/pkg/api/handlers/libpod/info.go new file mode 100644 index 000000000..cbf03aa17 --- /dev/null +++ b/pkg/api/handlers/libpod/info.go @@ -0,0 +1,18 @@ +package libpod + +import ( + "net/http" + + "github.com/containers/libpod/libpod" + "github.com/containers/libpod/pkg/api/handlers/utils" +) + +func GetInfo(w http.ResponseWriter, r *http.Request) { + runtime := r.Context().Value("runtime").(*libpod.Runtime) + info, err := runtime.Info() + if err != nil { + utils.InternalServerError(w, err) + return + } + utils.WriteResponse(w, http.StatusOK, info) +} diff --git a/pkg/api/handlers/libpod/swagger.go b/pkg/api/handlers/libpod/swagger.go index 1fad2dd1a..5dbc33098 100644 --- a/pkg/api/handlers/libpod/swagger.go +++ b/pkg/api/handlers/libpod/swagger.go @@ -5,6 +5,7 @@ import ( "os" "github.com/containers/image/v5/manifest" + "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/pkg/api/handlers/utils" "github.com/containers/libpod/pkg/domain/entities" "github.com/pkg/errors" @@ -76,6 +77,13 @@ type swagRmPodResponse struct { Body entities.PodRmReport } +// Info +// swagger:response InfoResponse +type swagInfoResponse struct { + // in:body + Body define.Info +} + func ServeSwagger(w http.ResponseWriter, r *http.Request) { path := DefaultPodmanSwaggerSpec if p, found := os.LookupEnv("PODMAN_SWAGGER_SPEC"); found { |