delegator.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 compose
  14. import (
  15. "context"
  16. "github.com/compose-spec/compose-go/types"
  17. )
  18. // ServiceDelegator implements Service by delegating to another implementation. This allows lazy init
  19. type ServiceDelegator struct {
  20. Delegate Service
  21. }
  22. //Build implements Service interface
  23. func (s *ServiceDelegator) Build(ctx context.Context, project *types.Project, options BuildOptions) error {
  24. return s.Delegate.Build(ctx, project, options)
  25. }
  26. //Push implements Service interface
  27. func (s *ServiceDelegator) Push(ctx context.Context, project *types.Project, options PushOptions) error {
  28. return s.Delegate.Push(ctx, project, options)
  29. }
  30. //Pull implements Service interface
  31. func (s *ServiceDelegator) Pull(ctx context.Context, project *types.Project, options PullOptions) error {
  32. return s.Delegate.Pull(ctx, project, options)
  33. }
  34. //Create implements Service interface
  35. func (s *ServiceDelegator) Create(ctx context.Context, project *types.Project, options CreateOptions) error {
  36. return s.Delegate.Create(ctx, project, options)
  37. }
  38. //Start implements Service interface
  39. func (s *ServiceDelegator) Start(ctx context.Context, project *types.Project, options StartOptions) error {
  40. return s.Delegate.Start(ctx, project, options)
  41. }
  42. //Restart implements Service interface
  43. func (s *ServiceDelegator) Restart(ctx context.Context, project *types.Project, options RestartOptions) error {
  44. return s.Delegate.Restart(ctx, project, options)
  45. }
  46. //Stop implements Service interface
  47. func (s *ServiceDelegator) Stop(ctx context.Context, project *types.Project, options StopOptions) error {
  48. return s.Delegate.Stop(ctx, project, options)
  49. }
  50. //Up implements Service interface
  51. func (s *ServiceDelegator) Up(ctx context.Context, project *types.Project, options UpOptions) error {
  52. return s.Delegate.Up(ctx, project, options)
  53. }
  54. //Down implements Service interface
  55. func (s *ServiceDelegator) Down(ctx context.Context, project string, options DownOptions) error {
  56. return s.Delegate.Down(ctx, project, options)
  57. }
  58. //Logs implements Service interface
  59. func (s *ServiceDelegator) Logs(ctx context.Context, project string, consumer LogConsumer, options LogOptions) error {
  60. return s.Delegate.Logs(ctx, project, consumer, options)
  61. }
  62. //Ps implements Service interface
  63. func (s *ServiceDelegator) Ps(ctx context.Context, project string, options PsOptions) ([]ContainerSummary, error) {
  64. return s.Delegate.Ps(ctx, project, options)
  65. }
  66. //List implements Service interface
  67. func (s *ServiceDelegator) List(ctx context.Context, options ListOptions) ([]Stack, error) {
  68. return s.Delegate.List(ctx, options)
  69. }
  70. //Convert implements Service interface
  71. func (s *ServiceDelegator) Convert(ctx context.Context, project *types.Project, options ConvertOptions) ([]byte, error) {
  72. return s.Delegate.Convert(ctx, project, options)
  73. }
  74. //Kill implements Service interface
  75. func (s *ServiceDelegator) Kill(ctx context.Context, project *types.Project, options KillOptions) error {
  76. return s.Delegate.Kill(ctx, project, options)
  77. }
  78. //RunOneOffContainer implements Service interface
  79. func (s *ServiceDelegator) RunOneOffContainer(ctx context.Context, project *types.Project, options RunOptions) (int, error) {
  80. return s.Delegate.RunOneOffContainer(ctx, project, options)
  81. }
  82. //Remove implements Service interface
  83. func (s *ServiceDelegator) Remove(ctx context.Context, project *types.Project, options RemoveOptions) ([]string, error) {
  84. return s.Delegate.Remove(ctx, project, options)
  85. }
  86. //Exec implements Service interface
  87. func (s *ServiceDelegator) Exec(ctx context.Context, project *types.Project, options RunOptions) (int, error) {
  88. return s.Delegate.Exec(ctx, project, options)
  89. }
  90. //Copy implements Service interface
  91. func (s *ServiceDelegator) Copy(ctx context.Context, project *types.Project, options CopyOptions) error {
  92. return s.Delegate.Copy(ctx, project, options)
  93. }
  94. //Pause implements Service interface
  95. func (s *ServiceDelegator) Pause(ctx context.Context, project string, options PauseOptions) error {
  96. return s.Delegate.Pause(ctx, project, options)
  97. }
  98. //UnPause implements Service interface
  99. func (s *ServiceDelegator) UnPause(ctx context.Context, project string, options PauseOptions) error {
  100. return s.Delegate.UnPause(ctx, project, options)
  101. }
  102. //Top implements Service interface
  103. func (s *ServiceDelegator) Top(ctx context.Context, project string, services []string) ([]ContainerProcSummary, error) {
  104. return s.Delegate.Top(ctx, project, services)
  105. }
  106. //Events implements Service interface
  107. func (s *ServiceDelegator) Events(ctx context.Context, project string, options EventsOptions) error {
  108. return s.Delegate.Events(ctx, project, options)
  109. }
  110. //Port implements Service interface
  111. func (s *ServiceDelegator) Port(ctx context.Context, project string, service string, port int, options PortOptions) (string, int, error) {
  112. return s.Delegate.Port(ctx, project, service, port, options)
  113. }
  114. //Images implements Service interface
  115. func (s *ServiceDelegator) Images(ctx context.Context, project string, options ImagesOptions) ([]ImageSummary, error) {
  116. return s.Delegate.Images(ctx, project, options)
  117. }