github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/cli/internal/test/network/client.go (about) 1 package network 2 3 import ( 4 "context" 5 6 "github.com/docker/docker/api/types" 7 "github.com/docker/docker/api/types/filters" 8 "github.com/docker/docker/api/types/network" 9 ) 10 11 // FakeClient is a fake NetworkAPIClient 12 type FakeClient struct { 13 NetworkInspectFunc func(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) 14 } 15 16 // NetworkConnect fakes connecting to a network 17 func (c *FakeClient) NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error { 18 return nil 19 } 20 21 // NetworkCreate fakes creating a network 22 func (c *FakeClient) NetworkCreate(_ context.Context, _ string, options types.NetworkCreate) (types.NetworkCreateResponse, error) { 23 return types.NetworkCreateResponse{}, nil 24 } 25 26 // NetworkDisconnect fakes disconnecting from a network 27 func (c *FakeClient) NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error { 28 return nil 29 } 30 31 // NetworkInspect fakes inspecting a network 32 func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) { 33 if c.NetworkInspectFunc != nil { 34 return c.NetworkInspectFunc(ctx, networkID, options) 35 } 36 return types.NetworkResource{}, nil 37 } 38 39 // NetworkInspectWithRaw fakes inspecting a network with a raw response 40 func (c *FakeClient) NetworkInspectWithRaw(_ context.Context, _ string, _ types.NetworkInspectOptions) (types.NetworkResource, []byte, error) { 41 return types.NetworkResource{}, nil, nil 42 } 43 44 // NetworkList fakes listing networks 45 func (c *FakeClient) NetworkList(_ context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { 46 return nil, nil 47 } 48 49 // NetworkRemove fakes removing networks 50 func (c *FakeClient) NetworkRemove(ctx context.Context, networkID string) error { 51 return nil 52 } 53 54 // NetworksPrune fakes pruning networks 55 func (c *FakeClient) NetworksPrune(_ context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) { 56 return types.NetworksPruneReport{}, nil 57 }