api.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/compose"
  7. )
  8. //go:generate mockgen -destination=./api_mock.go -self_package "github.com/docker/ecs-plugin/pkg/amazon/sdk" -package=sdk . 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 compose.LogConsumer) error
  33. }
  34. type secretsAPI interface {
  35. CreateSecret(ctx context.Context, secret compose.Secret) (string, error)
  36. InspectSecret(ctx context.Context, id string) (compose.Secret, error)
  37. ListSecrets(ctx context.Context) ([]compose.Secret, error)
  38. DeleteSecret(ctx context.Context, id string, recover bool) error
  39. }
  40. type listAPI interface {
  41. DescribeServices(ctx context.Context, cluster string, project string) ([]compose.ServiceStatus, error)
  42. }
  43. type waitAPI interface {
  44. GetStackID(ctx context.Context, name string) (string, error)
  45. WaitStackComplete(ctx context.Context, name string, operation int) error
  46. DescribeStackEvents(ctx context.Context, stackID string) ([]*cf.StackEvent, error)
  47. }