()
| 51 | } |
| 52 | |
| 53 | func (cfg *SQSConfig) fillDefaults() error { |
| 54 | if cfg.AwsRegion == "" { |
| 55 | cfg.AwsRegion = "us-west-2" |
| 56 | } |
| 57 | |
| 58 | switch sqsFormatType(strings.ToLower(cfg.MessageFormat)) { |
| 59 | case sqsFormatSNS, "": |
| 60 | cfg.format = sqsFormatJSON |
| 61 | cfg.MessageExpression = "Message" |
| 62 | case sqsFormatPlain: |
| 63 | cfg.format = sqsFormatPlain |
| 64 | case sqsFormatS3ObjectCreated: |
| 65 | cfg.format = sqsFormatJSON |
| 66 | cfg.MessageExpression = `Records[*].join('/',['s3:/', s3.bucket.name, s3.object.key]) | [0]` |
| 67 | case sqsFormatJSON: |
| 68 | cfg.format = sqsFormatJSON |
| 69 | if cfg.MessageExpression == "" { |
| 70 | return fmt.Errorf("MessageExpression is required with json MessageFormat") |
| 71 | } |
| 72 | default: |
| 73 | return fmt.Errorf("unknown MessageFormat %q", cfg.MessageFormat) |
| 74 | } |
| 75 | |
| 76 | return nil |
| 77 | } |
| 78 | |
| 79 | type sqsFormatType string |
| 80 |
no test coverage detected