1
0
mirror of https://github.com/rancher/os.git synced 2025-07-05 02:56:13 +00:00
os/vendor/github.com/docker/libcompose/project/client_factory.go
2016-05-23 17:22:40 -07:00

36 lines
932 B
Go

package project
import (
"github.com/docker/engine-api/client"
composeclient "github.com/docker/libcompose/docker/client"
)
// ClientFactory is a factory to create docker clients.
type ClientFactory interface {
// Create constructs a Docker client for the given service. The passed in
// config may be nil in which case a generic client for the project should
// be returned.
Create(service Service) client.APIClient
}
type defaultClientFactory struct {
client client.APIClient
}
// NewDefaultClientFactory creates and returns the default client factory that uses
// github.com/docker/engine-api client.
func NewDefaultClientFactory(opts composeclient.Options) (ClientFactory, error) {
client, err := composeclient.Create(opts)
if err != nil {
return nil, err
}
return &defaultClientFactory{
client: client,
}, nil
}
func (s *defaultClientFactory) Create(service Service) client.APIClient {
return s.client
}