diff options
author | Jhon Honce <jhonce@redhat.com> | 2022-05-19 10:27:31 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2022-05-19 15:24:18 -0700 |
commit | 5b79cf15a0226dc3dad5053615ee652823376cd3 (patch) | |
tree | 066e0b6e5fde4af49e7113ab48c277a55a60c22a /pkg/api/handlers/compat/info.go | |
parent | 913caaa9b1de2b63692c9bae15120208194c9eb3 (diff) | |
download | podman-5b79cf15a0226dc3dad5053615ee652823376cd3.tar.gz podman-5b79cf15a0226dc3dad5053615ee652823376cd3.tar.bz2 podman-5b79cf15a0226dc3dad5053615ee652823376cd3.zip |
Swagger refactor/cleanup
* Remove duplicate or unused types and constants
* Move all documetation-only models and responses into swagger package
* Remove all unecessary names, go-swagger will determine names from
struct declarations
* Use Libpod suffix to differentiate between compat and libpod models
and responses. Taken from swagger:operation declarations.
* Models and responses that start with lowercase are for swagger use
only while uppercase are used "as is" in the code and swagger comments
* Used gofumpt on new code
```release-note
```
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/api/handlers/compat/info.go')
-rw-r--r-- | pkg/api/handlers/compat/info.go | 141 |
1 files changed, 71 insertions, 70 deletions
diff --git a/pkg/api/handlers/compat/info.go b/pkg/api/handlers/compat/info.go index 6286fdaee..85547570a 100644 --- a/pkg/api/handlers/compat/info.go +++ b/pkg/api/handlers/compat/info.go @@ -53,75 +53,76 @@ func GetInfo(w http.ResponseWriter, r *http.Request) { // FIXME: Need to expose if runtime supports Checkpointing // liveRestoreEnabled := criu.CheckForCriu() && configInfo.RuntimeSupportsCheckpoint() - info := &handlers.Info{Info: docker.Info{ - Architecture: goRuntime.GOARCH, - BridgeNfIP6tables: !sysInfo.BridgeNFCallIP6TablesDisabled, - BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled, - CPUCfsPeriod: sysInfo.CPUCfsPeriod, - CPUCfsQuota: sysInfo.CPUCfsQuota, - CPUSet: sysInfo.Cpuset, - CPUShares: sysInfo.CPUShares, - CgroupDriver: configInfo.Engine.CgroupManager, - ClusterAdvertise: "", - ClusterStore: "", - ContainerdCommit: docker.Commit{}, - Containers: infoData.Store.ContainerStore.Number, - ContainersPaused: stateInfo[define.ContainerStatePaused], - ContainersRunning: stateInfo[define.ContainerStateRunning], - ContainersStopped: stateInfo[define.ContainerStateStopped] + stateInfo[define.ContainerStateExited], - Debug: log.IsLevelEnabled(log.DebugLevel), - DefaultRuntime: configInfo.Engine.OCIRuntime, - DockerRootDir: infoData.Store.GraphRoot, - Driver: infoData.Store.GraphDriverName, - DriverStatus: getGraphStatus(infoData.Store.GraphStatus), - ExperimentalBuild: true, - GenericResources: nil, - HTTPProxy: getEnv("http_proxy"), - HTTPSProxy: getEnv("https_proxy"), - ID: uuid.New().String(), - IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled, - Images: infoData.Store.ImageStore.Number, - IndexServerAddress: "", - InitBinary: "", - InitCommit: docker.Commit{}, - Isolation: "", - KernelMemoryTCP: false, - KernelVersion: infoData.Host.Kernel, - Labels: nil, - LiveRestoreEnabled: false, - LoggingDriver: "", - MemTotal: infoData.Host.MemTotal, - MemoryLimit: sysInfo.MemoryLimit, - NCPU: goRuntime.NumCPU(), - NEventsListener: 0, - NFd: getFdCount(), - NGoroutines: goRuntime.NumGoroutine(), - Name: infoData.Host.Hostname, - NoProxy: getEnv("no_proxy"), - OSType: goRuntime.GOOS, - OSVersion: infoData.Host.Distribution.Version, - OomKillDisable: sysInfo.OomKillDisable, - OperatingSystem: infoData.Host.Distribution.Distribution, - PidsLimit: sysInfo.PidsLimit, - Plugins: docker.PluginsInfo{ - Volume: infoData.Plugins.Volume, - Network: infoData.Plugins.Network, - Log: infoData.Plugins.Log, + info := &handlers.Info{ + Info: docker.Info{ + Architecture: goRuntime.GOARCH, + BridgeNfIP6tables: !sysInfo.BridgeNFCallIP6TablesDisabled, + BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled, + CPUCfsPeriod: sysInfo.CPUCfsPeriod, + CPUCfsQuota: sysInfo.CPUCfsQuota, + CPUSet: sysInfo.Cpuset, + CPUShares: sysInfo.CPUShares, + CgroupDriver: configInfo.Engine.CgroupManager, + ClusterAdvertise: "", + ClusterStore: "", + ContainerdCommit: docker.Commit{}, + Containers: infoData.Store.ContainerStore.Number, + ContainersPaused: stateInfo[define.ContainerStatePaused], + ContainersRunning: stateInfo[define.ContainerStateRunning], + ContainersStopped: stateInfo[define.ContainerStateStopped] + stateInfo[define.ContainerStateExited], + Debug: log.IsLevelEnabled(log.DebugLevel), + DefaultRuntime: configInfo.Engine.OCIRuntime, + DockerRootDir: infoData.Store.GraphRoot, + Driver: infoData.Store.GraphDriverName, + DriverStatus: getGraphStatus(infoData.Store.GraphStatus), + ExperimentalBuild: true, + GenericResources: nil, + HTTPProxy: getEnv("http_proxy"), + HTTPSProxy: getEnv("https_proxy"), + ID: uuid.New().String(), + IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled, + Images: infoData.Store.ImageStore.Number, + IndexServerAddress: "", + InitBinary: "", + InitCommit: docker.Commit{}, + Isolation: "", + KernelMemoryTCP: false, + KernelVersion: infoData.Host.Kernel, + Labels: nil, + LiveRestoreEnabled: false, + LoggingDriver: "", + MemTotal: infoData.Host.MemTotal, + MemoryLimit: sysInfo.MemoryLimit, + NCPU: goRuntime.NumCPU(), + NEventsListener: 0, + NFd: getFdCount(), + NGoroutines: goRuntime.NumGoroutine(), + Name: infoData.Host.Hostname, + NoProxy: getEnv("no_proxy"), + OSType: goRuntime.GOOS, + OSVersion: infoData.Host.Distribution.Version, + OomKillDisable: sysInfo.OomKillDisable, + OperatingSystem: infoData.Host.Distribution.Distribution, + PidsLimit: sysInfo.PidsLimit, + Plugins: docker.PluginsInfo{ + Volume: infoData.Plugins.Volume, + Network: infoData.Plugins.Network, + Log: infoData.Plugins.Log, + }, + ProductLicense: "Apache-2.0", + RegistryConfig: getServiceConfig(runtime), + RuncCommit: docker.Commit{}, + Runtimes: getRuntimes(configInfo), + SecurityOptions: getSecOpts(sysInfo), + ServerVersion: versionInfo.Version, + SwapLimit: sysInfo.SwapLimit, + Swarm: swarm.Info{ + LocalNodeState: swarm.LocalNodeStateInactive, + }, + SystemStatus: nil, + SystemTime: time.Now().Format(time.RFC3339Nano), + Warnings: []string{}, }, - ProductLicense: "Apache-2.0", - RegistryConfig: getServiceConfig(runtime), - RuncCommit: docker.Commit{}, - Runtimes: getRuntimes(configInfo), - SecurityOptions: getSecOpts(sysInfo), - ServerVersion: versionInfo.Version, - SwapLimit: sysInfo.SwapLimit, - Swarm: swarm.Info{ - LocalNodeState: swarm.LocalNodeStateInactive, - }, - SystemStatus: nil, - SystemTime: time.Now().Format(time.RFC3339Nano), - Warnings: []string{}, - }, BuildahVersion: infoData.Host.BuildahVersion, CPURealtimePeriod: sysInfo.CPURealtimePeriod, CPURealtimeRuntime: sysInfo.CPURealtimeRuntime, @@ -186,7 +187,7 @@ func getSecOpts(sysInfo *sysinfo.SysInfo) []string { } func getRuntimes(configInfo *config.Config) map[string]docker.Runtime { - var runtimes = map[string]docker.Runtime{} + runtimes := map[string]docker.Runtime{} for name, paths := range configInfo.Engine.OCIRuntimes { runtimes[name] = docker.Runtime{ Path: paths[0], @@ -206,7 +207,7 @@ func getFdCount() (count int) { // Just ignoring Container errors here... func getContainersState(r *libpod.Runtime) map[define.ContainerStatus]int { - var states = map[define.ContainerStatus]int{} + states := map[define.ContainerStatus]int{} ctnrs, err := r.GetAllContainers() if err == nil { for _, ctnr := range ctnrs { |