Fix podman-remote info to show registry data

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2020-01-06 17:00:21 -05:00
parent c41fd09a8d
commit d52a4dc2d4
5 changed files with 43 additions and 27 deletions

15
API.md
View File

@ -235,6 +235,8 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in
[type InfoPodmanBinary](#InfoPodmanBinary) [type InfoPodmanBinary](#InfoPodmanBinary)
[type InfoRegistry](#InfoRegistry)
[type InfoStore](#InfoStore) [type InfoStore](#InfoStore)
[type KubePodService](#KubePodService) [type KubePodService](#KubePodService)
@ -1840,6 +1842,15 @@ go_version [string](https://godoc.org/builtin#string)
podman_version [string](https://godoc.org/builtin#string) podman_version [string](https://godoc.org/builtin#string)
git_commit [string](https://godoc.org/builtin#string) git_commit [string](https://godoc.org/builtin#string)
### <a name="InfoRegistry"></a>type InfoRegistry
InfoRegistry describes the host's registry information
search [[]string](#[]string)
insecure [[]string](#[]string)
blocked [[]string](#[]string)
### <a name="InfoStore"></a>type InfoStore ### <a name="InfoStore"></a>type InfoStore
InfoStore describes the host's storage informatoin InfoStore describes the host's storage informatoin
@ -1952,9 +1963,7 @@ PodmanInfo describes the Podman host and build
host [InfoHost](#InfoHost) host [InfoHost](#InfoHost)
registries [[]string](#[]string) registries [InfoRegistry](#InfoRegistry)
insecure_registries [[]string](#[]string)
store [InfoStore](#InfoStore) store [InfoStore](#InfoStore)

View File

@ -245,6 +245,13 @@ type InfoGraphStatus (
supports_d_type: string supports_d_type: string
) )
# InfoRegistry describes the host's registry information
type InfoRegistry (
search: []string,
insecure: []string,
blocked: []string
)
# InfoStore describes the host's storage informatoin # InfoStore describes the host's storage informatoin
type InfoStore ( type InfoStore (
containers: int, containers: int,
@ -267,8 +274,7 @@ type InfoPodmanBinary (
# PodmanInfo describes the Podman host and build # PodmanInfo describes the Podman host and build
type PodmanInfo ( type PodmanInfo (
host: InfoHost, host: InfoHost,
registries: []string, registries: InfoRegistry,
insecure_registries: []string,
store: InfoStore, store: InfoStore,
podman: InfoPodmanBinary podman: InfoPodmanBinary
) )

View File

@ -14,12 +14,11 @@ func (r RemoteRuntime) Info() ([]define.InfoData, error) {
// TODO the varlink implementation for info should be updated to match the output for regular info // TODO the varlink implementation for info should be updated to match the output for regular info
var ( var (
reply []define.InfoData reply []define.InfoData
regInfo map[string]interface{}
hostInfo map[string]interface{} hostInfo map[string]interface{}
store map[string]interface{} store map[string]interface{}
) )
registries := make(map[string]interface{})
insecureRegistries := make(map[string]interface{})
info, err := iopodman.GetInfo().Call(r.Conn) info, err := iopodman.GetInfo().Call(r.Conn)
if err != nil { if err != nil {
return nil, err return nil, err
@ -39,13 +38,16 @@ func (r RemoteRuntime) Info() ([]define.InfoData, error) {
} }
json.Unmarshal(s, &store) json.Unmarshal(s, &store)
registries["registries"] = info.Registries // info.Registries -> map[string]interface{}
insecureRegistries["registries"] = info.Insecure_registries reg, err := json.Marshal(info.Registries)
if err != nil {
return nil, err
}
json.Unmarshal(reg, &regInfo)
// Add everything to the reply // Add everything to the reply
reply = append(reply, define.InfoData{Type: "host", Data: hostInfo}) reply = append(reply, define.InfoData{Type: "host", Data: hostInfo})
reply = append(reply, define.InfoData{Type: "registries", Data: registries}) reply = append(reply, define.InfoData{Type: "registries", Data: regInfo})
reply = append(reply, define.InfoData{Type: "insecure registries", Data: insecureRegistries})
reply = append(reply, define.InfoData{Type: "store", Data: store}) reply = append(reply, define.InfoData{Type: "store", Data: store})
return reply, nil return reply, nil
} }

View File

@ -9,6 +9,7 @@ import (
goruntime "runtime" goruntime "runtime"
"time" "time"
"github.com/containers/image/v5/pkg/sysregistriesv2"
"github.com/containers/libpod/cmd/podman/varlink" "github.com/containers/libpod/cmd/podman/varlink"
"github.com/containers/libpod/libpod/define" "github.com/containers/libpod/libpod/define"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -37,9 +38,6 @@ func (i *LibpodAPI) GetInfo(call iopodman.VarlinkCall) error {
if err != nil { if err != nil {
return err return err
} }
var (
registries, insecureRegistries []string
)
podmanInfo := iopodman.PodmanInfo{} podmanInfo := iopodman.PodmanInfo{}
info, err := i.Runtime.Info() info, err := i.Runtime.Info()
if err != nil { if err != nil {
@ -90,22 +88,25 @@ func (i *LibpodAPI) GetInfo(call iopodman.VarlinkCall) error {
Graph_status: graphStatus, Graph_status: graphStatus,
} }
// Registry information if any is stored as the second list item
if len(info) > 2 { if len(info) > 2 {
registriesInterface := info[2].Data["registries"] for key, val := range info[2].Data {
if registriesInterface != nil { if key == "search" {
registries = registriesInterface.([]string) podmanInfo.Registries.Search = val.([]string)
} continue
} }
if len(info) > 3 { regData := val.(sysregistriesv2.Registry)
insecureRegistriesInterface := info[3].Data["registries"] if regData.Insecure {
if insecureRegistriesInterface != nil { podmanInfo.Registries.Insecure = append(podmanInfo.Registries.Insecure, key)
insecureRegistries = insecureRegistriesInterface.([]string) }
if regData.Blocked {
podmanInfo.Registries.Blocked = append(podmanInfo.Registries.Blocked, key)
}
} }
} }
podmanInfo.Store = infoStore podmanInfo.Store = infoStore
podmanInfo.Podman = pmaninfo podmanInfo.Podman = pmaninfo
podmanInfo.Registries = registries
podmanInfo.Insecure_registries = insecureRegistries
return call.ReplyGetInfo(podmanInfo) return call.ReplyGetInfo(podmanInfo)
} }

View File

@ -1,5 +1,3 @@
// +build !remoteclient
package integration package integration
import ( import (