diff options
Diffstat (limited to 'pkg/api/handlers/compat/info.go')
-rw-r--r-- | pkg/api/handlers/compat/info.go | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/pkg/api/handlers/compat/info.go b/pkg/api/handlers/compat/info.go index 42a513002..6286fdaee 100644 --- a/pkg/api/handlers/compat/info.go +++ b/pkg/api/handlers/compat/info.go @@ -11,6 +11,7 @@ import ( "github.com/containers/common/pkg/config" "github.com/containers/common/pkg/sysinfo" + "github.com/containers/image/v5/pkg/sysregistriesv2" "github.com/containers/podman/v4/libpod" "github.com/containers/podman/v4/libpod/define" "github.com/containers/podman/v4/pkg/api/handlers" @@ -32,18 +33,18 @@ func GetInfo(w http.ResponseWriter, r *http.Request) { infoData, err := runtime.Info() if err != nil { - utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain system memory info")) + utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain system memory info")) return } configInfo, err := runtime.GetConfig() if err != nil { - utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain runtime config")) + utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain runtime config")) return } versionInfo, err := define.GetVersion() if err != nil { - utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain podman versions")) + utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to obtain podman versions")) return } stateInfo := getContainersState(runtime) @@ -108,7 +109,7 @@ func GetInfo(w http.ResponseWriter, r *http.Request) { Log: infoData.Plugins.Log, }, ProductLicense: "Apache-2.0", - RegistryConfig: new(registry.ServiceConfig), + RegistryConfig: getServiceConfig(runtime), RuncCommit: docker.Commit{}, Runtimes: getRuntimes(configInfo), SecurityOptions: getSecOpts(sysInfo), @@ -133,6 +134,37 @@ func GetInfo(w http.ResponseWriter, r *http.Request) { utils.WriteResponse(w, http.StatusOK, info) } +func getServiceConfig(runtime *libpod.Runtime) *registry.ServiceConfig { + var indexConfs map[string]*registry.IndexInfo + + regs, err := sysregistriesv2.GetRegistries(runtime.SystemContext()) + if err == nil { + indexConfs = make(map[string]*registry.IndexInfo, len(regs)) + for _, reg := range regs { + mirrors := make([]string, len(reg.Mirrors)) + for i, mirror := range reg.Mirrors { + mirrors[i] = mirror.Location + } + indexConfs[reg.Prefix] = ®istry.IndexInfo{ + Name: reg.Prefix, + Mirrors: mirrors, + Secure: !reg.Insecure, + } + } + } else { + log.Warnf("failed to get registries configuration: %v", err) + indexConfs = make(map[string]*registry.IndexInfo) + } + + return ®istry.ServiceConfig{ + AllowNondistributableArtifactsCIDRs: make([]*registry.NetIPNet, 0), + AllowNondistributableArtifactsHostnames: make([]string, 0), + InsecureRegistryCIDRs: make([]*registry.NetIPNet, 0), + IndexConfigs: indexConfs, + Mirrors: make([]string, 0), + } +} + func getGraphStatus(storeInfo map[string]string) [][2]string { graphStatus := make([][2]string, 0, len(storeInfo)) for k, v := range storeInfo { |