Skip to content

Commit

Permalink
resource/servicebus_subscription_rule: Fix the correlation_filter opt…
Browse files Browse the repository at this point in the history
…ional values (#1565)

Fixes: #1537

This was a simple fix to make sure that we were not passing empty strings
to the API. When passing empty strings, it was including those strings
in the subscription rule

We should only set the part of the rule if it is required as, technically,
a rule of sys.To = `` is actually value
  • Loading branch information
stack72 authored and tombuildsstuff committed Jul 13, 2018
1 parent ee414c3 commit 629f6fe
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions azurerm/resource_arm_servicebus_subscription_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,38 @@ func expandAzureRmServiceBusCorrelationFilter(d *schema.ResourceData) (*serviceb
return nil, fmt.Errorf("At least one property must be set in the `correlation_filter` block")
}

correlationFilter := servicebus.CorrelationFilter{
CorrelationID: utils.String(correlationID),
MessageID: utils.String(messageID),
To: utils.String(to),
ReplyTo: utils.String(replyTo),
Label: utils.String(label),
SessionID: utils.String(sessionID),
ReplyToSessionID: utils.String(replyToSessionID),
ContentType: utils.String(contentType),
correlationFilter := servicebus.CorrelationFilter{}

if correlationID != "" {
correlationFilter.CorrelationID = utils.String(correlationID)
}

if messageID != "" {
correlationFilter.MessageID = utils.String(messageID)
}

if to != "" {
correlationFilter.To = utils.String(to)
}

if replyTo != "" {
correlationFilter.ReplyTo = utils.String(replyTo)
}

if label != "" {
correlationFilter.Label = utils.String(label)
}

if sessionID != "" {
correlationFilter.SessionID = utils.String(sessionID)
}

if replyToSessionID != "" {
correlationFilter.ReplyToSessionID = utils.String(replyToSessionID)
}

if contentType != "" {
correlationFilter.ContentType = utils.String(contentType)
}

return &correlationFilter, nil
Expand Down

0 comments on commit 629f6fe

Please sign in to comment.