api.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 cloud
  14. import (
  15. "context"
  16. "github.com/docker/compose-cli/api/errdefs"
  17. )
  18. // Service cloud specific services
  19. type Service interface {
  20. // Login login to cloud provider
  21. Login(ctx context.Context, params interface{}) error
  22. // Logout logout from cloud provider
  23. Logout(ctx context.Context) error
  24. // CreateContextData create data for cloud context
  25. CreateContextData(ctx context.Context, params interface{}) (contextData interface{}, description string, err error)
  26. }
  27. // NotImplementedCloudService to use for backend that don't provide cloud services
  28. func NotImplementedCloudService() (Service, error) {
  29. return notImplementedCloudService{}, nil
  30. }
  31. type notImplementedCloudService struct {
  32. }
  33. // Logout login to cloud provider
  34. func (cs notImplementedCloudService) Logout(ctx context.Context) error {
  35. return errdefs.ErrNotImplemented
  36. }
  37. func (cs notImplementedCloudService) Login(ctx context.Context, params interface{}) error {
  38. return errdefs.ErrNotImplemented
  39. }
  40. func (cs notImplementedCloudService) CreateContextData(ctx context.Context, params interface{}) (interface{}, string, error) {
  41. return nil, "", errdefs.ErrNotImplemented
  42. }