|
|
@@ -6,17 +6,31 @@ import (
|
|
|
"io"
|
|
|
|
|
|
"github.com/docker/api/backend"
|
|
|
+ "github.com/docker/api/compose"
|
|
|
"github.com/docker/api/containers"
|
|
|
)
|
|
|
|
|
|
-type containerService struct{}
|
|
|
+type apiService struct {
|
|
|
+ containerService
|
|
|
+ composeService
|
|
|
+}
|
|
|
+
|
|
|
+func (a *apiService) ContainerService() containers.Service {
|
|
|
+ return &a.containerService
|
|
|
+}
|
|
|
+
|
|
|
+func (a *apiService) ComposeService() compose.Service {
|
|
|
+ return &a.composeService
|
|
|
+}
|
|
|
|
|
|
func init() {
|
|
|
- backend.Register("example", "example", func(ctx context.Context) (interface{}, error) {
|
|
|
- return &containerService{}, nil
|
|
|
+ backend.Register("example", "example", func(ctx context.Context) (backend.Service, error) {
|
|
|
+ return &apiService{}, nil
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+type containerService struct{}
|
|
|
+
|
|
|
func (cs *containerService) List(ctx context.Context) ([]containers.Container, error) {
|
|
|
return []containers.Container{
|
|
|
{
|
|
|
@@ -44,3 +58,23 @@ func (cs *containerService) Logs(ctx context.Context, containerName string, requ
|
|
|
fmt.Fprintf(request.Writer, "Following logs for container %q", containerName)
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+type composeService struct{}
|
|
|
+
|
|
|
+func (cs *composeService) Up(ctx context.Context, opts compose.ProjectOptions) error {
|
|
|
+ prj, err := compose.ProjectFromOptions(&opts)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ fmt.Printf("Up command on project %q", prj.Name)
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (cs *composeService) Down(ctx context.Context, opts compose.ProjectOptions) error {
|
|
|
+ prj, err := compose.ProjectFromOptions(&opts)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ fmt.Printf("Down command on project %q", prj.Name)
|
|
|
+ return nil
|
|
|
+}
|