mirror of https://github.com/containers/podman.git
domain: move system structs to types sub-package
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
48a99c6514
commit
9231234203
|
|
@ -11,7 +11,6 @@ import (
|
|||
|
||||
"github.com/containers/podman/v4/libpod/define"
|
||||
"github.com/containers/podman/v4/pkg/bindings"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities/types"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
|
@ -63,9 +62,9 @@ func Events(ctx context.Context, eventChan chan types.Event, cancelChan chan boo
|
|||
}
|
||||
|
||||
// Prune removes all unused system data.
|
||||
func Prune(ctx context.Context, options *PruneOptions) (*entities.SystemPruneReport, error) {
|
||||
func Prune(ctx context.Context, options *PruneOptions) (*types.SystemPruneReport, error) {
|
||||
var (
|
||||
report entities.SystemPruneReport
|
||||
report types.SystemPruneReport
|
||||
)
|
||||
conn, err := bindings.GetClient(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -84,10 +83,10 @@ func Prune(ctx context.Context, options *PruneOptions) (*entities.SystemPruneRep
|
|||
return &report, response.Process(&report)
|
||||
}
|
||||
|
||||
func Version(ctx context.Context, options *VersionOptions) (*entities.SystemVersionReport, error) {
|
||||
func Version(ctx context.Context, options *VersionOptions) (*types.SystemVersionReport, error) {
|
||||
var (
|
||||
component entities.ComponentVersion
|
||||
report entities.SystemVersionReport
|
||||
component types.SystemComponentVersion
|
||||
report types.SystemVersionReport
|
||||
)
|
||||
if options == nil {
|
||||
options = new(VersionOptions)
|
||||
|
|
@ -135,8 +134,8 @@ func Version(ctx context.Context, options *VersionOptions) (*entities.SystemVers
|
|||
|
||||
// DiskUsage returns information about image, container, and volume disk
|
||||
// consumption
|
||||
func DiskUsage(ctx context.Context, options *DiskOptions) (*entities.SystemDfReport, error) {
|
||||
var report entities.SystemDfReport
|
||||
func DiskUsage(ctx context.Context, options *DiskOptions) (*types.SystemDfReport, error) {
|
||||
var report types.SystemDfReport
|
||||
if options == nil {
|
||||
options = new(DiskOptions)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ package entities
|
|||
import (
|
||||
"net"
|
||||
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
commonTypes "github.com/containers/common/libnetwork/types"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities/types"
|
||||
)
|
||||
|
||||
// NetworkListOptions describes options for listing networks in cli
|
||||
|
|
@ -82,16 +83,13 @@ type NetworkDisconnectOptions struct {
|
|||
// a container to a network
|
||||
type NetworkConnectOptions struct {
|
||||
Container string `json:"container"`
|
||||
types.PerNetworkOptions
|
||||
commonTypes.PerNetworkOptions
|
||||
}
|
||||
|
||||
// NetworkPruneReport containers the name of network and an error
|
||||
// associated in its pruning (removal)
|
||||
// swagger:model NetworkPruneReport
|
||||
type NetworkPruneReport struct {
|
||||
Name string
|
||||
Error error
|
||||
}
|
||||
type NetworkPruneReport = types.NetworkPruneReport
|
||||
|
||||
// NetworkPruneOptions describes options for pruning unused networks
|
||||
type NetworkPruneOptions struct {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
commonFlag "github.com/containers/common/pkg/flag"
|
||||
"github.com/containers/podman/v4/libpod/define"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities/types"
|
||||
"github.com/containers/podman/v4/pkg/specgen"
|
||||
"github.com/containers/podman/v4/pkg/util"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
|
|
@ -446,10 +447,7 @@ type PodPruneOptions struct {
|
|||
Force bool `json:"force" schema:"force"`
|
||||
}
|
||||
|
||||
type PodPruneReport struct {
|
||||
Err error
|
||||
Id string //nolint:revive,stylecheck
|
||||
}
|
||||
type PodPruneReport = types.PodPruneReport
|
||||
|
||||
type PodTopOptions struct {
|
||||
// CLI flags.
|
||||
|
|
|
|||
|
|
@ -1,129 +1,25 @@
|
|||
package entities
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/containers/podman/v4/libpod/define"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities/reports"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities/types"
|
||||
)
|
||||
|
||||
// ServiceOptions provides the input for starting an API and sidecar pprof services
|
||||
type ServiceOptions struct {
|
||||
CorsHeaders string // Cross-Origin Resource Sharing (CORS) headers
|
||||
PProfAddr string // Network address to bind pprof profiles service
|
||||
Timeout time.Duration // Duration of inactivity the service should wait before shutting down
|
||||
URI string // Path to unix domain socket service should listen on
|
||||
}
|
||||
|
||||
// SystemPruneOptions provides options to prune system.
|
||||
type SystemPruneOptions struct {
|
||||
All bool
|
||||
Volume bool
|
||||
Filters map[string][]string `json:"filters" schema:"filters"`
|
||||
External bool
|
||||
}
|
||||
|
||||
// SystemPruneReport provides report after system prune is executed.
|
||||
type SystemPruneReport struct {
|
||||
PodPruneReport []*PodPruneReport
|
||||
ContainerPruneReports []*reports.PruneReport
|
||||
ImagePruneReports []*reports.PruneReport
|
||||
NetworkPruneReports []*NetworkPruneReport
|
||||
VolumePruneReports []*reports.PruneReport
|
||||
ReclaimedSpace uint64
|
||||
}
|
||||
|
||||
// SystemMigrateOptions describes the options needed for the
|
||||
// cli to migrate runtimes of containers
|
||||
type SystemMigrateOptions struct {
|
||||
NewRuntime string
|
||||
}
|
||||
|
||||
// SystemDfOptions describes the options for getting df information
|
||||
type SystemDfOptions struct {
|
||||
Format string
|
||||
Verbose bool
|
||||
}
|
||||
|
||||
// SystemDfReport describes the response for df information
|
||||
type SystemDfReport struct {
|
||||
ImagesSize int64
|
||||
Images []*SystemDfImageReport
|
||||
Containers []*SystemDfContainerReport
|
||||
Volumes []*SystemDfVolumeReport
|
||||
}
|
||||
|
||||
// SystemDfImageReport describes an image for use with df
|
||||
type SystemDfImageReport struct {
|
||||
Repository string
|
||||
Tag string
|
||||
ImageID string
|
||||
Created time.Time
|
||||
Size int64
|
||||
SharedSize int64
|
||||
UniqueSize int64
|
||||
Containers int
|
||||
}
|
||||
|
||||
// SystemDfContainerReport describes a container for use with df
|
||||
type SystemDfContainerReport struct {
|
||||
ContainerID string
|
||||
Image string
|
||||
Command []string
|
||||
LocalVolumes int
|
||||
Size int64
|
||||
RWSize int64
|
||||
Created time.Time
|
||||
Status string
|
||||
Names string
|
||||
}
|
||||
|
||||
// SystemDfVolumeReport describes a volume and its size
|
||||
type SystemDfVolumeReport struct {
|
||||
VolumeName string
|
||||
Links int
|
||||
Size int64
|
||||
ReclaimableSize int64
|
||||
}
|
||||
|
||||
// SystemVersionReport describes version information about the running Podman service
|
||||
type SystemVersionReport struct {
|
||||
// Always populated
|
||||
Client *define.Version `json:",omitempty"`
|
||||
// May be populated, when in tunnel mode
|
||||
Server *define.Version `json:",omitempty"`
|
||||
}
|
||||
|
||||
// SystemUnshareOptions describes the options for the unshare command
|
||||
type SystemUnshareOptions struct {
|
||||
RootlessNetNS bool
|
||||
}
|
||||
|
||||
type ComponentVersion struct {
|
||||
types.Version
|
||||
}
|
||||
|
||||
// ListRegistriesReport is the report when querying for a sorted list of
|
||||
// registries which may be contacted during certain operations.
|
||||
type ListRegistriesReport struct {
|
||||
Registries []string
|
||||
}
|
||||
type ServiceOptions = types.ServiceOptions
|
||||
type SystemPruneOptions = types.SystemPruneOptions
|
||||
type SystemPruneReport = types.SystemPruneReport
|
||||
type SystemMigrateOptions = types.SystemMigrateOptions
|
||||
type SystemDfOptions = types.SystemDfOptions
|
||||
type SystemDfReport = types.SystemDfReport
|
||||
type SystemDfImageReport = types.SystemDfImageReport
|
||||
type SystemDfContainerReport = types.SystemDfContainerReport
|
||||
type SystemDfVolumeReport = types.SystemDfVolumeReport
|
||||
type SystemVersionReport = types.SystemVersionReport
|
||||
type SystemUnshareOptions = types.SystemUnshareOptions
|
||||
type ComponentVersion = types.SystemComponentVersion
|
||||
type ListRegistriesReport = types.ListRegistriesReport
|
||||
|
||||
// swagger:model AuthConfig
|
||||
type AuthConfig struct {
|
||||
types.AuthConfig
|
||||
}
|
||||
|
||||
// AuthReport describes the response for authentication check
|
||||
type AuthReport struct {
|
||||
IdentityToken string
|
||||
Status string
|
||||
}
|
||||
|
||||
// LocksReport describes any conflicts in Libpod's lock allocations that could
|
||||
// lead to deadlocks.
|
||||
type LocksReport struct {
|
||||
LockConflicts map[uint32][]string
|
||||
LocksHeld []uint32
|
||||
}
|
||||
type AuthConfig = types.AuthConfig
|
||||
type AuthReport = types.AuthReport
|
||||
type LocksReport = types.LocksReport
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package types
|
||||
|
||||
// NetworkPruneReport containers the name of network and an error
|
||||
// associated in its pruning (removal)
|
||||
// swagger:model NetworkPruneReport
|
||||
type NetworkPruneReport struct {
|
||||
Name string
|
||||
Error error
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package types
|
||||
|
||||
type PodPruneReport struct {
|
||||
Err error
|
||||
Id string //nolint:revive,stylecheck
|
||||
}
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/containers/podman/v4/libpod/define"
|
||||
"github.com/containers/podman/v4/pkg/domain/entities/reports"
|
||||
)
|
||||
|
||||
// ServiceOptions provides the input for starting an API and sidecar pprof services
|
||||
type ServiceOptions struct {
|
||||
CorsHeaders string // Cross-Origin Resource Sharing (CORS) headers
|
||||
PProfAddr string // Network address to bind pprof profiles service
|
||||
Timeout time.Duration // Duration of inactivity the service should wait before shutting down
|
||||
URI string // Path to unix domain socket service should listen on
|
||||
}
|
||||
|
||||
// SystemPruneOptions provides options to prune system.
|
||||
type SystemPruneOptions struct {
|
||||
All bool
|
||||
Volume bool
|
||||
Filters map[string][]string `json:"filters" schema:"filters"`
|
||||
External bool
|
||||
}
|
||||
|
||||
// SystemPruneReport provides report after system prune is executed.
|
||||
type SystemPruneReport struct {
|
||||
PodPruneReport []*PodPruneReport
|
||||
ContainerPruneReports []*reports.PruneReport
|
||||
ImagePruneReports []*reports.PruneReport
|
||||
NetworkPruneReports []*NetworkPruneReport
|
||||
VolumePruneReports []*reports.PruneReport
|
||||
ReclaimedSpace uint64
|
||||
}
|
||||
|
||||
// SystemMigrateOptions describes the options needed for the
|
||||
// cli to migrate runtimes of containers
|
||||
type SystemMigrateOptions struct {
|
||||
NewRuntime string
|
||||
}
|
||||
|
||||
// SystemDfOptions describes the options for getting df information
|
||||
type SystemDfOptions struct {
|
||||
Format string
|
||||
Verbose bool
|
||||
}
|
||||
|
||||
// SystemDfReport describes the response for df information
|
||||
type SystemDfReport struct {
|
||||
ImagesSize int64
|
||||
Images []*SystemDfImageReport
|
||||
Containers []*SystemDfContainerReport
|
||||
Volumes []*SystemDfVolumeReport
|
||||
}
|
||||
|
||||
// SystemDfImageReport describes an image for use with df
|
||||
type SystemDfImageReport struct {
|
||||
Repository string
|
||||
Tag string
|
||||
ImageID string
|
||||
Created time.Time
|
||||
Size int64
|
||||
SharedSize int64
|
||||
UniqueSize int64
|
||||
Containers int
|
||||
}
|
||||
|
||||
// SystemDfContainerReport describes a container for use with df
|
||||
type SystemDfContainerReport struct {
|
||||
ContainerID string
|
||||
Image string
|
||||
Command []string
|
||||
LocalVolumes int
|
||||
Size int64
|
||||
RWSize int64
|
||||
Created time.Time
|
||||
Status string
|
||||
Names string
|
||||
}
|
||||
|
||||
// SystemDfVolumeReport describes a volume and its size
|
||||
type SystemDfVolumeReport struct {
|
||||
VolumeName string
|
||||
Links int
|
||||
Size int64
|
||||
ReclaimableSize int64
|
||||
}
|
||||
|
||||
// SystemVersionReport describes version information about the running Podman service
|
||||
type SystemVersionReport struct {
|
||||
// Always populated
|
||||
Client *define.Version `json:",omitempty"`
|
||||
// May be populated, when in tunnel mode
|
||||
Server *define.Version `json:",omitempty"`
|
||||
}
|
||||
|
||||
// SystemUnshareOptions describes the options for the unshare command
|
||||
type SystemUnshareOptions struct {
|
||||
RootlessNetNS bool
|
||||
}
|
||||
|
||||
// ListRegistriesReport is the report when querying for a sorted list of
|
||||
// registries which may be contacted during certain operations.
|
||||
type ListRegistriesReport struct {
|
||||
Registries []string
|
||||
}
|
||||
|
||||
// AuthReport describes the response for authentication check
|
||||
type AuthReport struct {
|
||||
IdentityToken string
|
||||
Status string
|
||||
}
|
||||
|
||||
// LocksReport describes any conflicts in Libpod's lock allocations that could
|
||||
// lead to deadlocks.
|
||||
type LocksReport struct {
|
||||
LockConflicts map[uint32][]string
|
||||
LocksHeld []uint32
|
||||
}
|
||||
|
|
@ -27,3 +27,8 @@ type Version struct {
|
|||
Experimental bool `json:",omitempty"`
|
||||
BuildTime string `json:",omitempty"`
|
||||
}
|
||||
|
||||
// SystemComponentVersion is the type used by pkg/domain/entities
|
||||
type SystemComponentVersion struct {
|
||||
Version
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue