-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14834 from transcom/MAIN-B-22056_sns_sqs_deps_w_e…
…ndpoint Main b 22056 sns sqs deps w endpoint
- Loading branch information
Showing
46 changed files
with
2,386 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/pflag" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
const ( | ||
// ReceiverBackendFlag is the Receiver Backend Flag | ||
ReceiverBackendFlag string = "receiver-backend" | ||
// SNSTagsUpdatedTopicFlag is the SNS Tags Updated Topic Flag | ||
SNSTagsUpdatedTopicFlag string = "sns-tags-updated-topic" | ||
// SNSRegionFlag is the SNS Region flag | ||
SNSRegionFlag string = "sns-region" | ||
// SNSAccountId is the application's AWS account id | ||
SNSAccountId string = "aws-account-id" | ||
// ReceiverCleanupOnStartFlag is the Receiver Cleanup On Start Flag | ||
ReceiverCleanupOnStartFlag string = "receiver-cleanup-on-start" | ||
) | ||
|
||
// InitReceiverFlags initializes Storage command line flags | ||
func InitReceiverFlags(flag *pflag.FlagSet) { | ||
flag.String(ReceiverBackendFlag, "local", "Receiver backend to use, either local or sns_sqs.") | ||
flag.String(SNSTagsUpdatedTopicFlag, "", "SNS Topic for receiving event messages") | ||
flag.String(SNSRegionFlag, "", "Region used for SNS and SQS") | ||
flag.String(SNSAccountId, "", "SNS account Id") | ||
flag.Bool(ReceiverCleanupOnStartFlag, false, "Receiver will cleanup previous aws artifacts on start.") | ||
} | ||
|
||
// CheckReceiver validates Storage command line flags | ||
func CheckReceiver(v *viper.Viper) error { | ||
|
||
receiverBackend := v.GetString(ReceiverBackendFlag) | ||
if !stringSliceContains([]string{"local", "sns_sqs"}, receiverBackend) { | ||
return fmt.Errorf("invalid receiver_backend %s, expecting local or sns_sqs", receiverBackend) | ||
} | ||
|
||
receiverCleanupOnStart := v.GetString(ReceiverCleanupOnStartFlag) | ||
if !stringSliceContains([]string{"true", "false"}, receiverCleanupOnStart) { | ||
return fmt.Errorf("invalid receiver_cleanup_on_start %s, expecting true or false", receiverCleanupOnStart) | ||
} | ||
|
||
if receiverBackend == "sns_sqs" { | ||
r := v.GetString(SNSRegionFlag) | ||
if r == "" { | ||
return fmt.Errorf("invalid value for %s: %s", SNSRegionFlag, r) | ||
} | ||
topic := v.GetString(SNSTagsUpdatedTopicFlag) | ||
if topic == "" { | ||
return fmt.Errorf("invalid value for %s: %s", SNSTagsUpdatedTopicFlag, topic) | ||
} | ||
accountId := v.GetString(SNSAccountId) | ||
if topic == "" { | ||
return fmt.Errorf("invalid value for %s: %s", SNSAccountId, accountId) | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package cli | ||
|
||
func (suite *cliTestSuite) TestConfigReceiver() { | ||
suite.Setup(InitReceiverFlags, []string{}) | ||
suite.NoError(CheckReceiver(suite.viper)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.