Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix podman-remote info to show registry data #4802

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in

[type InfoPodmanBinary](#InfoPodmanBinary)

[type InfoRegistry](#InfoRegistry)

[type InfoStore](#InfoStore)

[type KubePodService](#KubePodService)
Expand Down Expand Up @@ -1840,6 +1842,15 @@ go_version [string](https://godoc.org/builtin#string)
podman_version [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

InfoStore describes the host's storage informatoin
Expand Down Expand Up @@ -1952,9 +1963,7 @@ PodmanInfo describes the Podman host and build

host [InfoHost](#InfoHost)

registries [[]string](#[]string)

insecure_registries [[]string](#[]string)
registries [InfoRegistry](#InfoRegistry)

store [InfoStore](#InfoStore)

Expand Down
10 changes: 8 additions & 2 deletions cmd/podman/varlink/io.podman.varlink
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ type InfoGraphStatus (
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
type InfoStore (
containers: int,
Expand All @@ -267,8 +274,7 @@ type InfoPodmanBinary (
# PodmanInfo describes the Podman host and build
type PodmanInfo (
host: InfoHost,
registries: []string,
insecure_registries: []string,
registries: InfoRegistry,
store: InfoStore,
podman: InfoPodmanBinary
)
Expand Down
14 changes: 8 additions & 6 deletions pkg/adapter/info_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
var (
reply []define.InfoData
regInfo map[string]interface{}
hostInfo map[string]interface{}
store map[string]interface{}
)

registries := make(map[string]interface{})
insecureRegistries := make(map[string]interface{})
info, err := iopodman.GetInfo().Call(r.Conn)
if err != nil {
return nil, err
Expand All @@ -39,13 +38,16 @@ func (r RemoteRuntime) Info() ([]define.InfoData, error) {
}
json.Unmarshal(s, &store)

registries["registries"] = info.Registries
insecureRegistries["registries"] = info.Insecure_registries
// info.Registries -> map[string]interface{}
reg, err := json.Marshal(info.Registries)
if err != nil {
return nil, err
}
json.Unmarshal(reg, &regInfo)

// Add everything to the reply
reply = append(reply, define.InfoData{Type: "host", Data: hostInfo})
reply = append(reply, define.InfoData{Type: "registries", Data: registries})
reply = append(reply, define.InfoData{Type: "insecure registries", Data: insecureRegistries})
reply = append(reply, define.InfoData{Type: "registries", Data: regInfo})
reply = append(reply, define.InfoData{Type: "store", Data: store})
return reply, nil
}
29 changes: 15 additions & 14 deletions pkg/varlinkapi/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
goruntime "runtime"
"time"

"github.com/containers/image/v5/pkg/sysregistriesv2"
"github.com/containers/libpod/cmd/podman/varlink"
"github.com/containers/libpod/libpod/define"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -37,9 +38,6 @@ func (i *LibpodAPI) GetInfo(call iopodman.VarlinkCall) error {
if err != nil {
return err
}
var (
registries, insecureRegistries []string
)
podmanInfo := iopodman.PodmanInfo{}
info, err := i.Runtime.Info()
if err != nil {
Expand Down Expand Up @@ -90,22 +88,25 @@ func (i *LibpodAPI) GetInfo(call iopodman.VarlinkCall) error {
Graph_status: graphStatus,
}

// Registry information if any is stored as the second list item
if len(info) > 2 {
registriesInterface := info[2].Data["registries"]
if registriesInterface != nil {
registries = registriesInterface.([]string)
}
}
if len(info) > 3 {
insecureRegistriesInterface := info[3].Data["registries"]
if insecureRegistriesInterface != nil {
insecureRegistries = insecureRegistriesInterface.([]string)
for key, val := range info[2].Data {
vrothberg marked this conversation as resolved.
Show resolved Hide resolved
if key == "search" {
podmanInfo.Registries.Search = val.([]string)
continue
}
vrothberg marked this conversation as resolved.
Show resolved Hide resolved
regData := val.(sysregistriesv2.Registry)
if regData.Insecure {
podmanInfo.Registries.Insecure = append(podmanInfo.Registries.Insecure, key)
}
if regData.Blocked {
podmanInfo.Registries.Blocked = append(podmanInfo.Registries.Blocked, key)
}
}

}
podmanInfo.Store = infoStore
podmanInfo.Podman = pmaninfo
podmanInfo.Registries = registries
podmanInfo.Insecure_registries = insecureRegistries
return call.ReplyGetInfo(podmanInfo)
}

Expand Down
2 changes: 0 additions & 2 deletions test/e2e/info_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build !remoteclient

package integration

import (
Expand Down