backend.go 1.8 KB

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