backend.go 771 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package backend
  2. import (
  3. "context"
  4. "github.com/aws/aws-sdk-go/aws"
  5. "github.com/aws/aws-sdk-go/aws/session"
  6. "github.com/docker/ecs-plugin/pkg/amazon/sdk"
  7. "github.com/docker/ecs-plugin/pkg/progress"
  8. )
  9. func NewBackend(profile string, region string) (*Backend, error) {
  10. sess, err := session.NewSessionWithOptions(session.Options{
  11. Profile: profile,
  12. SharedConfigState: session.SharedConfigEnable,
  13. Config: aws.Config{
  14. Region: aws.String(region),
  15. },
  16. })
  17. if err != nil {
  18. return nil, err
  19. }
  20. return &Backend{
  21. Region: region,
  22. api: sdk.NewAPI(sess),
  23. }, nil
  24. }
  25. type Backend struct {
  26. Region string
  27. api sdk.API
  28. writer progress.Writer
  29. }
  30. func (b *Backend) SetWriter(context context.Context) {
  31. b.writer = progress.ContextWriter(context)
  32. }