backend.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. "context"
  16. local_compose "github.com/docker/compose-cli/local/compose"
  17. "github.com/docker/docker/client"
  18. "github.com/docker/compose-cli/api/backend"
  19. "github.com/docker/compose-cli/api/cloud"
  20. "github.com/docker/compose-cli/api/compose"
  21. "github.com/docker/compose-cli/api/containers"
  22. "github.com/docker/compose-cli/api/context/store"
  23. "github.com/docker/compose-cli/api/resources"
  24. "github.com/docker/compose-cli/api/secrets"
  25. "github.com/docker/compose-cli/api/volumes"
  26. )
  27. const backendType = store.EcsLocalSimulationContextType
  28. func init() {
  29. backend.Register(backendType, backendType, service, getCloudService)
  30. }
  31. type ecsLocalSimulation struct {
  32. moby *client.Client
  33. compose compose.Service
  34. }
  35. func service(ctx context.Context) (backend.Service, error) {
  36. apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
  37. if err != nil {
  38. return nil, err
  39. }
  40. return &ecsLocalSimulation{
  41. moby: apiClient,
  42. compose: local_compose.NewComposeService(apiClient),
  43. }, nil
  44. }
  45. func getCloudService() (cloud.Service, error) {
  46. return ecsLocalSimulation{}, nil
  47. }
  48. func (e ecsLocalSimulation) ContainerService() containers.Service {
  49. return nil
  50. }
  51. func (e ecsLocalSimulation) VolumeService() volumes.Service {
  52. return nil
  53. }
  54. func (e ecsLocalSimulation) SecretsService() secrets.Service {
  55. return nil
  56. }
  57. func (e ecsLocalSimulation) ComposeService() compose.Service {
  58. return e
  59. }
  60. func (e ecsLocalSimulation) ResourceService() resources.Service {
  61. return nil
  62. }