aboutsummaryrefslogtreecommitdiff
path: root/pkg/adapter/info_remote.go
blob: 3b691ed173504867c17006c9872d46a996488d12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// +build remoteclient

package adapter

import (
	"encoding/json"

	"github.com/containers/libpod/cmd/podman/varlink"
	"github.com/containers/libpod/libpod"
)

// Info returns information for the host system and its components
func (r RemoteRuntime) Info() ([]libpod.InfoData, error) {
	// TODO the varlink implementation for info should be updated to match the output for regular info
	var (
		reply    []libpod.InfoData
		hostInfo map[string]interface{}
		store    map[string]interface{}
	)

	registries := make(map[string]interface{})
	insecureRegistries := make(map[string]interface{})
	conn, err := r.Connect()
	if err != nil {
		return nil, err
	}
	defer conn.Close()
	info, err := iopodman.GetInfo().Call(conn)
	if err != nil {
		return nil, err
	}

	// info.host -> map[string]interface{}
	h, err := json.Marshal(info.Host)
	if err != nil {
		return nil, err
	}
	json.Unmarshal(h, &hostInfo)

	// info.store -> map[string]interface{}
	s, err := json.Marshal(info.Store)
	if err != nil {
		return nil, err
	}
	json.Unmarshal(s, &store)

	registries["registries"] = info.Registries
	insecureRegistries["registries"] = info.Insecure_registries

	// Add everything to the reply
	reply = append(reply, libpod.InfoData{Type: "host", Data: hostInfo})
	reply = append(reply, libpod.InfoData{Type: "registries", Data: registries})
	reply = append(reply, libpod.InfoData{Type: "insecure registries", Data: insecureRegistries})
	reply = append(reply, libpod.InfoData{Type: "store", Data: store})
	return reply, nil
}