From f30ea76c13c964281f081485a3059d575da8ec84 Mon Sep 17 00:00:00 2001 From: Ryan Koval Date: Wed, 4 Aug 2021 14:15:57 -0500 Subject: [PATCH] added support for us-gov region domains --- awsworkflow/aws.go | 3 ++ tests/test_aws_config_file | 6 +++ tests/test_aws_credentials_file | 10 ++++- .../TestRun-$cn-north-1_elasticbeanstalk | 35 +++++++++++++++ workflow/.snapshots/TestRun-$us-east-1_@ | 44 ++++++++++++++++++- workflow/.snapshots/TestRun-@ | 44 ++++++++++++++++++- workflow/.snapshots/TestRun-@_$ | 44 ++++++++++++++++++- .../TestRun-@china_elasticbeanstalk | 35 +++++++++++++++ .../TestRun-@usgov_elasticbeanstalk | 35 +++++++++++++++ workflow/workflow_test.go | 9 ++++ 10 files changed, 261 insertions(+), 4 deletions(-) create mode 100644 workflow/.snapshots/TestRun-$cn-north-1_elasticbeanstalk create mode 100644 workflow/.snapshots/TestRun-@china_elasticbeanstalk create mode 100644 workflow/.snapshots/TestRun-@usgov_elasticbeanstalk diff --git a/awsworkflow/aws.go b/awsworkflow/aws.go index 6b93fa39..f8446933 100644 --- a/awsworkflow/aws.go +++ b/awsworkflow/aws.go @@ -52,12 +52,15 @@ func InitAWS(transport http.RoundTripper, profile *awsconfig.Profile, region *aw var defaultAwsConsoleDomain string = "console.aws.amazon.com" var defaultAwsConsoleDomainChina string = "console.amazonaws.cn" +var defaultAwsConsoleDomainUsGov string = "console.amazonaws-us-gov.com" func initAWSConsoleDomain(region string) { awsConsoleDomain := os.Getenv("ALRED_AWS_CONSOLE_SERVICES_WORKFLOW_AWS_CONSOLE_DOMAIN") if awsConsoleDomain == "" { if strings.HasPrefix(region, "cn-") { awsConsoleDomain = defaultAwsConsoleDomainChina + } else if strings.HasPrefix(region, "us-gov-") { + awsConsoleDomain = defaultAwsConsoleDomainUsGov } else { awsConsoleDomain = defaultAwsConsoleDomain } diff --git a/tests/test_aws_config_file b/tests/test_aws_config_file index 3276fe7b..4435ea7a 100644 --- a/tests/test_aws_config_file +++ b/tests/test_aws_config_file @@ -12,3 +12,9 @@ region = sa-east-1 [profile bogusprofile] region = bogus + +[profile usgov] +region = us-gov-east-1 + +[profile china] +region = cn-north-1 diff --git a/tests/test_aws_credentials_file b/tests/test_aws_credentials_file index cb009b38..db8d7b35 100644 --- a/tests/test_aws_credentials_file +++ b/tests/test_aws_credentials_file @@ -14,4 +14,12 @@ aws_secret_access_key=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy aws_access_key_id=BBBBBBBBBBBBBBBBBBBB aws_secret_access_key=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy -[bogusprofile] \ No newline at end of file +[bogusprofile] + +[usgov] +aws_access_key_id=BBBBBBBBBBBBBBBBBBBB +aws_secret_access_key=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy + +[china] +aws_access_key_id=BBBBBBBBBBBBBBBBBBBB +aws_secret_access_key=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy diff --git a/workflow/.snapshots/TestRun-$cn-north-1_elasticbeanstalk b/workflow/.snapshots/TestRun-$cn-north-1_elasticbeanstalk new file mode 100644 index 00000000..b0659c1b --- /dev/null +++ b/workflow/.snapshots/TestRun-$cn-north-1_elasticbeanstalk @@ -0,0 +1,35 @@ +([]*aw.Item) (len=1) { + (*aw.Item)({ + title: (string) (len=16) "elasticbeanstalk", + subtitle: (*string)((len=50) "🗂 Elastic Beanstalk – Run and Manage Web Apps"), + match: (*string)((len=34) "elasticbeanstalk Elastic Beanstalk"), + uid: (*string)((len=16) "elasticbeanstalk"), + autocomplete: (*string)((len=29) "$cn-north-1 elasticbeanstalk "), + arg: (*string)((len=93) "https://cn-north-1.console.amazonaws.cn/elasticbeanstalk/home?region=cn-north-1#/environments"), + valid: (bool) true, + file: (bool) false, + copytext: (*string)(), + largetype: (*string)(), + ql: (*string)(), + vars: (map[string]string) (len=1) { + (string) (len=6) "action": (string) (len=8) "open-url" + }, + mods: (map[aw.ModKey]*aw.Modifier) (len=1) { + (aw.ModKey) (len=3) "cmd": (*aw.Modifier)({ + Key: (aw.ModKey) (len=3) "cmd", + arg: (*string)(), + subtitle: (*string)((len=21) "Copy URL to clipboard"), + valid: (bool) false, + icon: (*aw.Icon)(), + vars: (map[string]string) (len=1) { + (string) (len=6) "action": (string) (len=17) "copy-to-clipboard" + } + }) + }, + icon: (*aw.Icon)({ + Value: (string) (len=27) "images/elasticbeanstalk.png", + Type: (aw.IconType) "" + }), + noUID: (bool) false + }) +} diff --git a/workflow/.snapshots/TestRun-$us-east-1_@ b/workflow/.snapshots/TestRun-$us-east-1_@ index b37c7935..936795e7 100644 --- a/workflow/.snapshots/TestRun-$us-east-1_@ +++ b/workflow/.snapshots/TestRun-$us-east-1_@ @@ -1,4 +1,46 @@ -([]*aw.Item) (len=5) { +([]*aw.Item) (len=7) { + (*aw.Item)({ + title: (string) (len=5) "china", + subtitle: (*string)((len=15) "🌎 cn-north-1"), + match: (*string)(), + uid: (*string)((len=5) "china"), + autocomplete: (*string)((len=18) "$us-east-1 @china "), + arg: (*string)(), + valid: (bool) false, + file: (bool) false, + copytext: (*string)(), + largetype: (*string)(), + ql: (*string)(), + vars: (map[string]string) { + }, + mods: (map[aw.ModKey]*aw.Modifier) , + icon: (*aw.Icon)({ + Value: (string) (len=78) "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Accounts.icns", + Type: (aw.IconType) "" + }), + noUID: (bool) false + }), + (*aw.Item)({ + title: (string) (len=5) "usgov", + subtitle: (*string)((len=18) "🌎 us-gov-east-1"), + match: (*string)(), + uid: (*string)((len=5) "usgov"), + autocomplete: (*string)((len=18) "$us-east-1 @usgov "), + arg: (*string)(), + valid: (bool) false, + file: (bool) false, + copytext: (*string)(), + largetype: (*string)(), + ql: (*string)(), + vars: (map[string]string) { + }, + mods: (map[aw.ModKey]*aw.Modifier) , + icon: (*aw.Icon)({ + Value: (string) (len=78) "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Accounts.icns", + Type: (aw.IconType) "" + }), + noUID: (bool) false + }), (*aw.Item)({ title: (string) (len=7) "default", subtitle: (*string)((len=14) "🌎 us-west-2"), diff --git a/workflow/.snapshots/TestRun-@ b/workflow/.snapshots/TestRun-@ index 680a6fcf..d76c8712 100644 --- a/workflow/.snapshots/TestRun-@ +++ b/workflow/.snapshots/TestRun-@ @@ -1,4 +1,46 @@ -([]*aw.Item) (len=5) { +([]*aw.Item) (len=7) { + (*aw.Item)({ + title: (string) (len=5) "china", + subtitle: (*string)((len=15) "🌎 cn-north-1"), + match: (*string)(), + uid: (*string)((len=5) "china"), + autocomplete: (*string)((len=7) "@china "), + arg: (*string)(), + valid: (bool) false, + file: (bool) false, + copytext: (*string)(), + largetype: (*string)(), + ql: (*string)(), + vars: (map[string]string) { + }, + mods: (map[aw.ModKey]*aw.Modifier) , + icon: (*aw.Icon)({ + Value: (string) (len=78) "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Accounts.icns", + Type: (aw.IconType) "" + }), + noUID: (bool) false + }), + (*aw.Item)({ + title: (string) (len=5) "usgov", + subtitle: (*string)((len=18) "🌎 us-gov-east-1"), + match: (*string)(), + uid: (*string)((len=5) "usgov"), + autocomplete: (*string)((len=7) "@usgov "), + arg: (*string)(), + valid: (bool) false, + file: (bool) false, + copytext: (*string)(), + largetype: (*string)(), + ql: (*string)(), + vars: (map[string]string) { + }, + mods: (map[aw.ModKey]*aw.Modifier) , + icon: (*aw.Icon)({ + Value: (string) (len=78) "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Accounts.icns", + Type: (aw.IconType) "" + }), + noUID: (bool) false + }), (*aw.Item)({ title: (string) (len=7) "default", subtitle: (*string)((len=14) "🌎 us-west-2"), diff --git a/workflow/.snapshots/TestRun-@_$ b/workflow/.snapshots/TestRun-@_$ index 2220d16f..1aa46ed6 100644 --- a/workflow/.snapshots/TestRun-@_$ +++ b/workflow/.snapshots/TestRun-@_$ @@ -1,4 +1,46 @@ -([]*aw.Item) (len=5) { +([]*aw.Item) (len=7) { + (*aw.Item)({ + title: (string) (len=5) "china", + subtitle: (*string)((len=15) "🌎 cn-north-1"), + match: (*string)(), + uid: (*string)((len=5) "china"), + autocomplete: (*string)((len=9) "@china $"), + arg: (*string)(), + valid: (bool) false, + file: (bool) false, + copytext: (*string)(), + largetype: (*string)(), + ql: (*string)(), + vars: (map[string]string) { + }, + mods: (map[aw.ModKey]*aw.Modifier) , + icon: (*aw.Icon)({ + Value: (string) (len=78) "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Accounts.icns", + Type: (aw.IconType) "" + }), + noUID: (bool) false + }), + (*aw.Item)({ + title: (string) (len=5) "usgov", + subtitle: (*string)((len=18) "🌎 us-gov-east-1"), + match: (*string)(), + uid: (*string)((len=5) "usgov"), + autocomplete: (*string)((len=9) "@usgov $"), + arg: (*string)(), + valid: (bool) false, + file: (bool) false, + copytext: (*string)(), + largetype: (*string)(), + ql: (*string)(), + vars: (map[string]string) { + }, + mods: (map[aw.ModKey]*aw.Modifier) , + icon: (*aw.Icon)({ + Value: (string) (len=78) "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Accounts.icns", + Type: (aw.IconType) "" + }), + noUID: (bool) false + }), (*aw.Item)({ title: (string) (len=7) "default", subtitle: (*string)((len=14) "🌎 us-west-2"), diff --git a/workflow/.snapshots/TestRun-@china_elasticbeanstalk b/workflow/.snapshots/TestRun-@china_elasticbeanstalk new file mode 100644 index 00000000..fdafe2e6 --- /dev/null +++ b/workflow/.snapshots/TestRun-@china_elasticbeanstalk @@ -0,0 +1,35 @@ +([]*aw.Item) (len=1) { + (*aw.Item)({ + title: (string) (len=16) "elasticbeanstalk", + subtitle: (*string)((len=50) "🗂 Elastic Beanstalk – Run and Manage Web Apps"), + match: (*string)((len=34) "elasticbeanstalk Elastic Beanstalk"), + uid: (*string)((len=16) "elasticbeanstalk"), + autocomplete: (*string)((len=24) "@china elasticbeanstalk "), + arg: (*string)((len=93) "https://cn-north-1.console.amazonaws.cn/elasticbeanstalk/home?region=cn-north-1#/environments"), + valid: (bool) true, + file: (bool) false, + copytext: (*string)(), + largetype: (*string)(), + ql: (*string)(), + vars: (map[string]string) (len=1) { + (string) (len=6) "action": (string) (len=8) "open-url" + }, + mods: (map[aw.ModKey]*aw.Modifier) (len=1) { + (aw.ModKey) (len=3) "cmd": (*aw.Modifier)({ + Key: (aw.ModKey) (len=3) "cmd", + arg: (*string)(), + subtitle: (*string)((len=21) "Copy URL to clipboard"), + valid: (bool) false, + icon: (*aw.Icon)(), + vars: (map[string]string) (len=1) { + (string) (len=6) "action": (string) (len=17) "copy-to-clipboard" + } + }) + }, + icon: (*aw.Icon)({ + Value: (string) (len=27) "images/elasticbeanstalk.png", + Type: (aw.IconType) "" + }), + noUID: (bool) false + }) +} diff --git a/workflow/.snapshots/TestRun-@usgov_elasticbeanstalk b/workflow/.snapshots/TestRun-@usgov_elasticbeanstalk new file mode 100644 index 00000000..6b572a11 --- /dev/null +++ b/workflow/.snapshots/TestRun-@usgov_elasticbeanstalk @@ -0,0 +1,35 @@ +([]*aw.Item) (len=1) { + (*aw.Item)({ + title: (string) (len=16) "elasticbeanstalk", + subtitle: (*string)((len=50) "🗂 Elastic Beanstalk – Run and Manage Web Apps"), + match: (*string)((len=34) "elasticbeanstalk Elastic Beanstalk"), + uid: (*string)((len=16) "elasticbeanstalk"), + autocomplete: (*string)((len=24) "@usgov elasticbeanstalk "), + arg: (*string)((len=107) "https://us-gov-east-1.console.amazonaws-us-gov.com/elasticbeanstalk/home?region=us-gov-east-1#/environments"), + valid: (bool) true, + file: (bool) false, + copytext: (*string)(), + largetype: (*string)(), + ql: (*string)(), + vars: (map[string]string) (len=1) { + (string) (len=6) "action": (string) (len=8) "open-url" + }, + mods: (map[aw.ModKey]*aw.Modifier) (len=1) { + (aw.ModKey) (len=3) "cmd": (*aw.Modifier)({ + Key: (aw.ModKey) (len=3) "cmd", + arg: (*string)(), + subtitle: (*string)((len=21) "Copy URL to clipboard"), + valid: (bool) false, + icon: (*aw.Icon)(), + vars: (map[string]string) (len=1) { + (string) (len=6) "action": (string) (len=17) "copy-to-clipboard" + } + }) + }, + icon: (*aw.Icon)({ + Value: (string) (len=27) "images/elasticbeanstalk.png", + Type: (aw.IconType) "" + }), + noUID: (bool) false + }) +} diff --git a/workflow/workflow_test.go b/workflow/workflow_test.go index e3f43772..b7e543f6 100644 --- a/workflow/workflow_test.go +++ b/workflow/workflow_test.go @@ -82,6 +82,15 @@ var tcs []testCase = []testCase{ { query: "$us-east-1 @profile3 elasticbeanstalk", }, + { + query: "$cn-north-1 elasticbeanstalk", + }, + { + query: "@usgov elasticbeanstalk", + }, + { + query: "@china elasticbeanstalk", + }, { query: "alex", },