mirror of
https://github.com/containers/podman.git
synced 2025-06-25 12:20:42 +08:00
bindings: network uses entities/types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/common/libnetwork/types"
|
"github.com/containers/common/libnetwork/types"
|
||||||
"github.com/containers/podman/v4/pkg/bindings"
|
"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"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -88,8 +88,8 @@ func Inspect(ctx context.Context, nameOrID string, _ *InspectOptions) (types.Net
|
|||||||
// Remove deletes a defined network configuration by name. The optional force boolean
|
// Remove deletes a defined network configuration by name. The optional force boolean
|
||||||
// will remove all containers associated with the network when set to true. A slice
|
// will remove all containers associated with the network when set to true. A slice
|
||||||
// of NetworkRemoveReports are returned.
|
// of NetworkRemoveReports are returned.
|
||||||
func Remove(ctx context.Context, nameOrID string, options *RemoveOptions) ([]*entities.NetworkRmReport, error) {
|
func Remove(ctx context.Context, nameOrID string, options *RemoveOptions) ([]*entitiesTypes.NetworkRmReport, error) {
|
||||||
var reports []*entities.NetworkRmReport
|
var reports []*entitiesTypes.NetworkRmReport
|
||||||
if options == nil {
|
if options == nil {
|
||||||
options = new(RemoveOptions)
|
options = new(RemoveOptions)
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ func Connect(ctx context.Context, networkName string, containerNameOrID string,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Connect sends everything in body
|
// Connect sends everything in body
|
||||||
connect := entities.NetworkConnectOptions{
|
connect := entitiesTypes.NetworkConnectOptions{
|
||||||
Container: containerNameOrID,
|
Container: containerNameOrID,
|
||||||
PerNetworkOptions: *options,
|
PerNetworkOptions: *options,
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ func Exists(ctx context.Context, nameOrID string, options *ExistsOptions) (bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prune removes unused networks
|
// Prune removes unused networks
|
||||||
func Prune(ctx context.Context, options *PruneOptions) ([]*entities.NetworkPruneReport, error) {
|
func Prune(ctx context.Context, options *PruneOptions) ([]*entitiesTypes.NetworkPruneReport, error) {
|
||||||
if options == nil {
|
if options == nil {
|
||||||
options = new(PruneOptions)
|
options = new(PruneOptions)
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ func Prune(ctx context.Context, options *PruneOptions) ([]*entities.NetworkPrune
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
prunedNetworks []*entities.NetworkPruneReport
|
prunedNetworks []*entitiesTypes.NetworkPruneReport
|
||||||
)
|
)
|
||||||
conn, err := bindings.GetClient(ctx)
|
conn, err := bindings.GetClient(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3,8 +3,7 @@ package entities
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
commonTypes "github.com/containers/common/libnetwork/types"
|
entitiesTypes "github.com/containers/podman/v4/pkg/domain/entities/types"
|
||||||
"github.com/containers/podman/v4/pkg/domain/entities/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NetworkListOptions describes options for listing networks in cli
|
// NetworkListOptions describes options for listing networks in cli
|
||||||
@ -22,11 +21,7 @@ type NetworkReloadOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NetworkReloadReport describes the results of reloading a container network.
|
// NetworkReloadReport describes the results of reloading a container network.
|
||||||
type NetworkReloadReport struct {
|
type NetworkReloadReport = entitiesTypes.NetworkReloadReport
|
||||||
//nolint:stylecheck,revive
|
|
||||||
Id string
|
|
||||||
Err error
|
|
||||||
}
|
|
||||||
|
|
||||||
// NetworkRmOptions describes options for removing networks
|
// NetworkRmOptions describes options for removing networks
|
||||||
type NetworkRmOptions struct {
|
type NetworkRmOptions struct {
|
||||||
@ -35,10 +30,7 @@ type NetworkRmOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NetworkRmReport describes the results of network removal
|
// NetworkRmReport describes the results of network removal
|
||||||
type NetworkRmReport struct {
|
type NetworkRmReport = entitiesTypes.NetworkRmReport
|
||||||
Name string
|
|
||||||
Err error
|
|
||||||
}
|
|
||||||
|
|
||||||
// NetworkCreateOptions describes options to create a network
|
// NetworkCreateOptions describes options to create a network
|
||||||
type NetworkCreateOptions struct {
|
type NetworkCreateOptions struct {
|
||||||
@ -68,9 +60,7 @@ type NetworkUpdateOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NetworkCreateReport describes a created network for the cli
|
// NetworkCreateReport describes a created network for the cli
|
||||||
type NetworkCreateReport struct {
|
type NetworkCreateReport = entitiesTypes.NetworkCreateReport
|
||||||
Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
// NetworkDisconnectOptions describes options for disconnecting
|
// NetworkDisconnectOptions describes options for disconnecting
|
||||||
// containers from networks
|
// containers from networks
|
||||||
@ -81,15 +71,12 @@ type NetworkDisconnectOptions struct {
|
|||||||
|
|
||||||
// NetworkConnectOptions describes options for connecting
|
// NetworkConnectOptions describes options for connecting
|
||||||
// a container to a network
|
// a container to a network
|
||||||
type NetworkConnectOptions struct {
|
type NetworkConnectOptions = entitiesTypes.NetworkConnectOptions
|
||||||
Container string `json:"container"`
|
|
||||||
commonTypes.PerNetworkOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
// NetworkPruneReport containers the name of network and an error
|
// NetworkPruneReport containers the name of network and an error
|
||||||
// associated in its pruning (removal)
|
// associated in its pruning (removal)
|
||||||
// swagger:model NetworkPruneReport
|
// swagger:model NetworkPruneReport
|
||||||
type NetworkPruneReport = types.NetworkPruneReport
|
type NetworkPruneReport = entitiesTypes.NetworkPruneReport
|
||||||
|
|
||||||
// NetworkPruneOptions describes options for pruning unused networks
|
// NetworkPruneOptions describes options for pruning unused networks
|
||||||
type NetworkPruneOptions struct {
|
type NetworkPruneOptions struct {
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
commonTypes "github.com/containers/common/libnetwork/types"
|
||||||
|
)
|
||||||
|
|
||||||
// NetworkPruneReport containers the name of network and an error
|
// NetworkPruneReport containers the name of network and an error
|
||||||
// associated in its pruning (removal)
|
// associated in its pruning (removal)
|
||||||
// swagger:model NetworkPruneReport
|
// swagger:model NetworkPruneReport
|
||||||
@ -7,3 +11,27 @@ type NetworkPruneReport struct {
|
|||||||
Name string
|
Name string
|
||||||
Error error
|
Error error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NetworkReloadReport describes the results of reloading a container network.
|
||||||
|
type NetworkReloadReport struct {
|
||||||
|
//nolint:stylecheck,revive
|
||||||
|
Id string
|
||||||
|
Err error
|
||||||
|
}
|
||||||
|
|
||||||
|
// NetworkConnectOptions describes options for connecting
|
||||||
|
// a container to a network
|
||||||
|
type NetworkConnectOptions struct {
|
||||||
|
Container string `json:"container"`
|
||||||
|
commonTypes.PerNetworkOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// NetworkRmReport describes the results of network removal
|
||||||
|
type NetworkRmReport struct {
|
||||||
|
Name string
|
||||||
|
Err error
|
||||||
|
}
|
||||||
|
|
||||||
|
type NetworkCreateReport struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user