api.go 1.5 KB

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