api.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package sdk
  2. import (
  3. "context"
  4. cf "github.com/aws/aws-sdk-go/service/cloudformation"
  5. "github.com/awslabs/goformation/v4/cloudformation"
  6. "github.com/docker/ecs-plugin/pkg/amazon/types"
  7. )
  8. //go:generate mockgen -destination=./api_mock.go -self_package "github.com/docker/ecs-plugin/pkg/amazon" -package=amazon . API
  9. type API interface {
  10. downAPI
  11. upAPI
  12. logsAPI
  13. secretsAPI
  14. listAPI
  15. }
  16. type upAPI interface {
  17. waitAPI
  18. GetDefaultVPC(ctx context.Context) (string, error)
  19. VpcExists(ctx context.Context, vpcID string) (bool, error)
  20. GetSubNets(ctx context.Context, vpcID string) ([]string, error)
  21. ClusterExists(ctx context.Context, name string) (bool, error)
  22. StackExists(ctx context.Context, name string) (bool, error)
  23. CreateStack(ctx context.Context, name string, template *cloudformation.Template, parameters map[string]string) error
  24. LoadBalancerExists(ctx context.Context, name string) (bool, error)
  25. GetLoadBalancerARN(ctx context.Context, name string) (string, error)
  26. }
  27. type downAPI interface {
  28. DeleteStack(ctx context.Context, name string) error
  29. DeleteCluster(ctx context.Context, name string) error
  30. }
  31. type logsAPI interface {
  32. GetLogs(ctx context.Context, name string, consumer types.LogConsumer) error
  33. }
  34. type secretsAPI interface {
  35. CreateSecret(ctx context.Context, secret types.Secret) (string, error)
  36. InspectSecret(ctx context.Context, id string) (types.Secret, error)
  37. ListSecrets(ctx context.Context) ([]types.Secret, error)
  38. DeleteSecret(ctx context.Context, id string, recover bool) error
  39. }
  40. type listAPI interface {
  41. ListTasks(ctx context.Context, cluster string, name string) ([]string, error)
  42. DescribeTasks(ctx context.Context, cluster string, arns ...string) ([]types.TaskStatus, error)
  43. GetPublicIPs(ctx context.Context, interfaces ...string) (map[string]string, error)
  44. }
  45. type waitAPI interface {
  46. GetStackID(ctx context.Context, name string) (string, error)
  47. WaitStackComplete(ctx context.Context, name string, operation int) error
  48. DescribeStackEvents(ctx context.Context, stackID string) ([]*cf.StackEvent, error)
  49. }