MCPcopy Create free account
hub / github.com/AdRoll/baker / fillDefaults

Method fillDefaults

input/sqs.go:53–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51}
52
53func (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
79type sqsFormatType string
80

Callers 1

NewSQSFunction · 0.45

Calls 1

sqsFormatTypeTypeAlias · 0.85

Tested by

no test coverage detected