backend.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. Copyright 2020 Docker Compose CLI authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package local
  14. import (
  15. local_compose "github.com/docker/compose-cli/local/compose"
  16. "github.com/docker/docker/client"
  17. "github.com/docker/compose-cli/api/backend"
  18. "github.com/docker/compose-cli/api/cloud"
  19. "github.com/docker/compose-cli/api/compose"
  20. "github.com/docker/compose-cli/api/containers"
  21. "github.com/docker/compose-cli/api/context/store"
  22. "github.com/docker/compose-cli/api/resources"
  23. "github.com/docker/compose-cli/api/secrets"
  24. "github.com/docker/compose-cli/api/volumes"
  25. )
  26. const backendType = store.EcsLocalSimulationContextType
  27. func init() {
  28. backend.Register(backendType, backendType, service, getCloudService)
  29. }
  30. type ecsLocalSimulation struct {
  31. moby *client.Client
  32. compose compose.Service
  33. }
  34. func service() (backend.Service, error) {
  35. apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
  36. if err != nil {
  37. return nil, err
  38. }
  39. return &ecsLocalSimulation{
  40. moby: apiClient,
  41. compose: local_compose.NewComposeService(apiClient),
  42. }, nil
  43. }
  44. func getCloudService() (cloud.Service, error) {
  45. return ecsLocalSimulation{}, nil
  46. }
  47. func (e ecsLocalSimulation) ContainerService() containers.Service {
  48. return nil
  49. }
  50. func (e ecsLocalSimulation) VolumeService() volumes.Service {
  51. return nil
  52. }
  53. func (e ecsLocalSimulation) SecretsService() secrets.Service {
  54. return nil
  55. }
  56. func (e ecsLocalSimulation) ComposeService() compose.Service {
  57. return e
  58. }
  59. func (e ecsLocalSimulation) ResourceService() resources.Service {
  60. return nil
  61. }