2017-05-26 12:15:23 -04:00
|
|
|
package network
|
|
|
|
|
|
|
|
import (
|
2018-05-03 21:02:44 -04:00
|
|
|
"context"
|
|
|
|
|
2017-05-26 12:15:23 -04:00
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/api/types/filters"
|
|
|
|
"github.com/docker/docker/api/types/network"
|
|
|
|
)
|
|
|
|
|
|
|
|
// FakeClient is a fake NetworkAPIClient
|
|
|
|
type FakeClient struct {
|
2017-06-12 22:53:53 -04:00
|
|
|
NetworkInspectFunc func(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error)
|
2017-05-26 12:15:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkConnect fakes connecting to a network
|
|
|
|
func (c *FakeClient) NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkCreate fakes creating a network
|
2017-06-09 17:16:56 -04:00
|
|
|
func (c *FakeClient) NetworkCreate(_ context.Context, _ string, options types.NetworkCreate) (types.NetworkCreateResponse, error) {
|
2017-05-26 12:15:23 -04:00
|
|
|
return types.NetworkCreateResponse{}, nil
|
|
|
|
}
|
|
|
|
|
2017-06-09 17:16:56 -04:00
|
|
|
// NetworkDisconnect fakes disconnecting from a network
|
2017-05-26 12:15:23 -04:00
|
|
|
func (c *FakeClient) NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkInspect fakes inspecting a network
|
2017-06-12 22:53:53 -04:00
|
|
|
func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) {
|
2017-05-26 12:15:23 -04:00
|
|
|
if c.NetworkInspectFunc != nil {
|
2017-06-12 22:53:53 -04:00
|
|
|
return c.NetworkInspectFunc(ctx, networkID, options)
|
2017-05-26 12:15:23 -04:00
|
|
|
}
|
|
|
|
return types.NetworkResource{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkInspectWithRaw fakes inspecting a network with a raw response
|
2017-06-09 17:16:56 -04:00
|
|
|
func (c *FakeClient) NetworkInspectWithRaw(_ context.Context, _ string, _ types.NetworkInspectOptions) (types.NetworkResource, []byte, error) {
|
2017-05-26 12:15:23 -04:00
|
|
|
return types.NetworkResource{}, nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkList fakes listing networks
|
2017-06-09 17:16:56 -04:00
|
|
|
func (c *FakeClient) NetworkList(_ context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
|
2017-05-26 12:15:23 -04:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkRemove fakes removing networks
|
|
|
|
func (c *FakeClient) NetworkRemove(ctx context.Context, networkID string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NetworksPrune fakes pruning networks
|
2017-06-09 17:16:56 -04:00
|
|
|
func (c *FakeClient) NetworksPrune(_ context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) {
|
2017-05-26 12:15:23 -04:00
|
|
|
return types.NetworksPruneReport{}, nil
|
|
|
|
}
|