bindings: pods uses entities/types

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2024-01-25 15:34:51 +01:00
parent 668d517af9
commit f18ebad1e6
3 changed files with 74 additions and 58 deletions

View File

@ -8,17 +8,17 @@ import (
"github.com/containers/podman/v4/pkg/api/handlers"
"github.com/containers/podman/v4/pkg/bindings"
"github.com/containers/podman/v4/pkg/domain/entities"
entitiesTypes "github.com/containers/podman/v4/pkg/domain/entities/types"
"github.com/containers/podman/v4/pkg/errorhandling"
jsoniter "github.com/json-iterator/go"
)
func CreatePodFromSpec(ctx context.Context, spec *entities.PodSpec) (*entities.PodCreateReport, error) {
func CreatePodFromSpec(ctx context.Context, spec *entitiesTypes.PodSpec) (*entitiesTypes.PodCreateReport, error) {
var (
pcr entities.PodCreateReport
pcr entitiesTypes.PodCreateReport
)
if spec == nil {
spec = new(entities.PodSpec)
spec = new(entitiesTypes.PodSpec)
}
conn, err := bindings.GetClient(ctx)
if err != nil {
@ -54,9 +54,9 @@ func Exists(ctx context.Context, nameOrID string, options *ExistsOptions) (bool,
}
// Inspect returns low-level information about the given pod.
func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) (*entities.PodInspectReport, error) {
func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) (*entitiesTypes.PodInspectReport, error) {
var (
report entities.PodInspectReport
report entitiesTypes.PodInspectReport
)
if options == nil {
options = new(InspectOptions)
@ -77,9 +77,9 @@ func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) (*en
// Kill sends a SIGTERM to all the containers in a pod. The optional signal parameter
// can be used to override SIGTERM.
func Kill(ctx context.Context, nameOrID string, options *KillOptions) (*entities.PodKillReport, error) {
func Kill(ctx context.Context, nameOrID string, options *KillOptions) (*entitiesTypes.PodKillReport, error) {
var (
report entities.PodKillReport
report entitiesTypes.PodKillReport
)
if options == nil {
options = new(KillOptions)
@ -102,8 +102,8 @@ func Kill(ctx context.Context, nameOrID string, options *KillOptions) (*entities
}
// Pause pauses all running containers in a given pod.
func Pause(ctx context.Context, nameOrID string, options *PauseOptions) (*entities.PodPauseReport, error) {
var report entities.PodPauseReport
func Pause(ctx context.Context, nameOrID string, options *PauseOptions) (*entitiesTypes.PodPauseReport, error) {
var report entitiesTypes.PodPauseReport
if options == nil {
options = new(PauseOptions)
}
@ -123,8 +123,8 @@ func Pause(ctx context.Context, nameOrID string, options *PauseOptions) (*entiti
// Prune by default removes all non-running pods in local storage.
// And with force set true removes all pods.
func Prune(ctx context.Context, options *PruneOptions) ([]*entities.PodPruneReport, error) {
var reports []*entities.PodPruneReport
func Prune(ctx context.Context, options *PruneOptions) ([]*entitiesTypes.PodPruneReport, error) {
var reports []*entitiesTypes.PodPruneReport
if options == nil {
options = new(PruneOptions)
}
@ -144,9 +144,9 @@ func Prune(ctx context.Context, options *PruneOptions) ([]*entities.PodPruneRepo
// List returns all pods in local storage. The optional filters parameter can
// be used to refine which pods should be listed.
func List(ctx context.Context, options *ListOptions) ([]*entities.ListPodsReport, error) {
func List(ctx context.Context, options *ListOptions) ([]*entitiesTypes.ListPodsReport, error) {
var (
podsReports []*entities.ListPodsReport
podsReports []*entitiesTypes.ListPodsReport
)
if options == nil {
options = new(ListOptions)
@ -169,8 +169,8 @@ func List(ctx context.Context, options *ListOptions) ([]*entities.ListPodsReport
}
// Restart restarts all containers in a pod.
func Restart(ctx context.Context, nameOrID string, options *RestartOptions) (*entities.PodRestartReport, error) {
var report entities.PodRestartReport
func Restart(ctx context.Context, nameOrID string, options *RestartOptions) (*entitiesTypes.PodRestartReport, error) {
var report entitiesTypes.PodRestartReport
if options == nil {
options = new(RestartOptions)
}
@ -190,8 +190,8 @@ func Restart(ctx context.Context, nameOrID string, options *RestartOptions) (*en
// Remove deletes a Pod from local storage. The optional force parameter denotes
// that the Pod can be removed even if in a running state.
func Remove(ctx context.Context, nameOrID string, options *RemoveOptions) (*entities.PodRmReport, error) {
var report entities.PodRmReport
func Remove(ctx context.Context, nameOrID string, options *RemoveOptions) (*entitiesTypes.PodRmReport, error) {
var report entitiesTypes.PodRmReport
if options == nil {
options = new(RemoveOptions)
}
@ -213,8 +213,8 @@ func Remove(ctx context.Context, nameOrID string, options *RemoveOptions) (*enti
}
// Start starts all containers in a pod.
func Start(ctx context.Context, nameOrID string, options *StartOptions) (*entities.PodStartReport, error) {
var report entities.PodStartReport
func Start(ctx context.Context, nameOrID string, options *StartOptions) (*entitiesTypes.PodStartReport, error) {
var report entitiesTypes.PodStartReport
if options == nil {
options = new(StartOptions)
}
@ -239,8 +239,8 @@ func Start(ctx context.Context, nameOrID string, options *StartOptions) (*entiti
// Stop stops all containers in a Pod. The optional timeout parameter can be
// used to override the timeout before the container is killed.
func Stop(ctx context.Context, nameOrID string, options *StopOptions) (*entities.PodStopReport, error) {
var report entities.PodStopReport
func Stop(ctx context.Context, nameOrID string, options *StopOptions) (*entitiesTypes.PodStopReport, error) {
var report entitiesTypes.PodStopReport
if options == nil {
options = new(StopOptions)
}
@ -302,12 +302,12 @@ func Top(ctx context.Context, nameOrID string, options *TopOptions) ([]string, e
}
// Unpause unpauses all paused containers in a Pod.
func Unpause(ctx context.Context, nameOrID string, options *UnpauseOptions) (*entities.PodUnpauseReport, error) {
func Unpause(ctx context.Context, nameOrID string, options *UnpauseOptions) (*entitiesTypes.PodUnpauseReport, error) {
if options == nil {
options = new(UnpauseOptions)
}
_ = options
var report entities.PodUnpauseReport
var report entitiesTypes.PodUnpauseReport
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, err
@ -322,7 +322,7 @@ func Unpause(ctx context.Context, nameOrID string, options *UnpauseOptions) (*en
}
// Stats display resource-usage statistics of one or more pods.
func Stats(ctx context.Context, namesOrIDs []string, options *StatsOptions) ([]*entities.PodStatsReport, error) {
func Stats(ctx context.Context, namesOrIDs []string, options *StatsOptions) ([]*entitiesTypes.PodStatsReport, error) {
if options == nil {
options = new(StatsOptions)
}
@ -338,7 +338,7 @@ func Stats(ctx context.Context, namesOrIDs []string, options *StatsOptions) ([]*
params.Add("namesOrIDs", i)
}
var reports []*entities.PodStatsReport
var reports []*entitiesTypes.PodStatsReport
response, err := conn.DoRequest(ctx, nil, http.MethodGet, "/pods/stats", params, nil)
if err != nil {
return nil, err