Skip to content

Commit

Permalink
Merge pull request crossplane-contrib#1737 from devopsmindset/master
Browse files Browse the repository at this point in the history
Add FilterPolicyScope SNS property
  • Loading branch information
Christopher Haar authored Apr 28, 2023
2 parents e0960d3 + 720c790 commit 7bb6fbf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apis/sns/v1beta1/subscription_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ type SubscriptionParameters struct {
// +optional
FilterPolicy *string `json:"filterPolicy,omitempty"`

// FilterPolicyScope can be MessageAttributes or MessageBody
// +optional
FilterPolicyScope *string `json:"filterPolicyScope,omitempty"`

// When set to true, enables raw message delivery
// to Amazon SQS or HTTP/S endpoints. This eliminates the need for the endpoints
// to process JSON formatting, which is otherwise created for Amazon SNS
Expand Down
5 changes: 5 additions & 0 deletions apis/sns/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package/crds/sns.aws.crossplane.io_subscriptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ spec:
receive only a subset of messages, rather than receiving every
message published to the topic.
type: string
filterPolicyScope:
description: FilterPolicyScope can be MessageAttributes or MessageBody
type: string
protocol:
description: The subscription's protocol.
type: string
Expand Down
5 changes: 5 additions & 0 deletions pkg/clients/sns/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const (
SubscriptionDeliveryPolicy = "DeliveryPolicy"
// SubscriptionFilterPolicy is FilterPolicy of SNS Subscription
SubscriptionFilterPolicy = "FilterPolicy"
// SubscriptionFilterPolicyScope is FilterPolicyScope of SNS Subscription
SubscriptionFilterPolicyScope = "FilterPolicyScope"
// SubscriptionRawMessageDelivery is RawMessageDelivery of SNS Subscription
SubscriptionRawMessageDelivery = "RawMessageDelivery"
// SubscriptionRedrivePolicy is RedrivePolicy of SNS Subscription
Expand Down Expand Up @@ -105,6 +107,7 @@ func GenerateSubscriptionObservation(attr map[string]string) v1beta1.Subscriptio
func LateInitializeSubscription(in *v1beta1.SubscriptionParameters, subAttributes map[string]string) {
in.DeliveryPolicy = awsclients.LateInitializeStringPtr(in.DeliveryPolicy, awsclients.String(subAttributes[SubscriptionDeliveryPolicy]))
in.FilterPolicy = awsclients.LateInitializeStringPtr(in.FilterPolicy, awsclients.String(subAttributes[SubscriptionFilterPolicy]))
in.FilterPolicyScope = awsclients.LateInitializeStringPtr(in.FilterPolicyScope, awsclients.String(subAttributes[SubscriptionFilterPolicyScope]))
in.RawMessageDelivery = awsclients.LateInitializeStringPtr(in.RawMessageDelivery, awsclients.String(subAttributes[SubscriptionRawMessageDelivery]))
in.RedrivePolicy = awsclients.LateInitializeStringPtr(in.RedrivePolicy, awsclients.String(subAttributes[SubscriptionRedrivePolicy]))
}
Expand All @@ -114,6 +117,7 @@ func getSubAttributes(p v1beta1.SubscriptionParameters) map[string]string {
return map[string]string{
SubscriptionDeliveryPolicy: aws.ToString(p.DeliveryPolicy),
SubscriptionFilterPolicy: aws.ToString(p.FilterPolicy),
SubscriptionFilterPolicyScope: aws.ToString(p.FilterPolicyScope),
SubscriptionRawMessageDelivery: aws.ToString(p.RawMessageDelivery),
SubscriptionRedrivePolicy: aws.ToString(p.RedrivePolicy),
}
Expand All @@ -137,6 +141,7 @@ func GetChangedSubAttributes(p v1beta1.SubscriptionParameters, attrs map[string]
func IsSNSSubscriptionAttributesUpToDate(p v1beta1.SubscriptionParameters, subAttributes map[string]string) bool {
return aws.ToString(p.DeliveryPolicy) == subAttributes[SubscriptionDeliveryPolicy] &&
aws.ToString(p.FilterPolicy) == subAttributes[SubscriptionFilterPolicy] &&
aws.ToString(p.FilterPolicyScope) == subAttributes[SubscriptionFilterPolicyScope] &&
aws.ToString(p.RawMessageDelivery) == subAttributes[SubscriptionRawMessageDelivery] &&
aws.ToString(p.RedrivePolicy) == subAttributes[SubscriptionRedrivePolicy]
}
Expand Down

0 comments on commit 7bb6fbf

Please sign in to comment.