2020-06-18 16:13:24 +02:00
|
|
|
/*
|
2020-09-22 12:13:00 +02:00
|
|
|
Copyright 2020 Docker Compose CLI authors
|
2020-06-18 16:13:24 +02:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-06-12 15:00:30 +02:00
|
|
|
package local
|
2020-05-04 19:50:01 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-11-18 17:18:41 +01:00
|
|
|
|
2020-05-04 19:50:01 +02:00
|
|
|
"github.com/docker/docker/client"
|
|
|
|
|
2020-09-07 13:22:08 +02:00
|
|
|
"github.com/docker/compose-cli/api/compose"
|
|
|
|
"github.com/docker/compose-cli/api/containers"
|
2020-10-12 10:18:45 +02:00
|
|
|
"github.com/docker/compose-cli/api/resources"
|
2020-09-07 13:22:08 +02:00
|
|
|
"github.com/docker/compose-cli/api/secrets"
|
2020-09-07 18:23:28 +02:00
|
|
|
"github.com/docker/compose-cli/api/volumes"
|
2020-08-21 17:24:53 +02:00
|
|
|
"github.com/docker/compose-cli/backend"
|
|
|
|
"github.com/docker/compose-cli/context/cloud"
|
2020-12-08 11:53:36 +01:00
|
|
|
local_compose "github.com/docker/compose-cli/local/compose"
|
2020-05-04 19:50:01 +02:00
|
|
|
)
|
|
|
|
|
2020-06-12 15:00:30 +02:00
|
|
|
type local struct {
|
2020-12-08 11:53:36 +01:00
|
|
|
containerService *containerService
|
|
|
|
volumeService *volumeService
|
|
|
|
composeService compose.Service
|
2020-05-04 19:50:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2020-06-12 15:00:30 +02:00
|
|
|
backend.Register("local", "local", service, cloud.NotImplementedCloudService)
|
2020-05-04 19:50:01 +02:00
|
|
|
}
|
|
|
|
|
2020-05-28 17:37:59 +02:00
|
|
|
func service(ctx context.Context) (backend.Service, error) {
|
2020-11-17 13:44:51 +01:00
|
|
|
apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
2020-05-04 19:50:01 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-06-12 15:00:30 +02:00
|
|
|
return &local{
|
2020-11-03 21:01:56 +01:00
|
|
|
containerService: &containerService{apiClient},
|
2020-11-03 21:15:14 +01:00
|
|
|
volumeService: &volumeService{apiClient},
|
2020-12-08 11:53:36 +01:00
|
|
|
composeService: local_compose.NewComposeService(apiClient),
|
2020-05-04 19:50:01 +02:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2020-11-13 09:38:21 +01:00
|
|
|
func (s *local) ContainerService() containers.Service {
|
|
|
|
return s.containerService
|
2020-05-04 19:50:01 +02:00
|
|
|
}
|
|
|
|
|
2020-11-13 09:38:21 +01:00
|
|
|
func (s *local) ComposeService() compose.Service {
|
2020-11-26 14:44:55 +01:00
|
|
|
return s.composeService
|
2020-05-04 19:50:01 +02:00
|
|
|
}
|
|
|
|
|
2020-11-13 09:38:21 +01:00
|
|
|
func (s *local) SecretsService() secrets.Service {
|
2020-08-18 09:13:58 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-13 09:38:21 +01:00
|
|
|
func (s *local) VolumeService() volumes.Service {
|
|
|
|
return s.volumeService
|
2020-09-07 14:39:19 +02:00
|
|
|
}
|
|
|
|
|
2020-11-13 09:38:21 +01:00
|
|
|
func (s *local) ResourceService() resources.Service {
|
2020-10-12 10:18:45 +02:00
|
|
|
return nil
|
|
|
|
}
|