Skip to content

Commit

Permalink
Merge pull request openshift#392 from geowa4/OSD-15754-proxy-aws-conn…
Browse files Browse the repository at this point in the history
…ections

Forego grace period and force proxy to be set
  • Loading branch information
openshift-merge-robot authored Jun 7, 2023
2 parents d819cf2 + de3fe48 commit 348936a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
3 changes: 1 addition & 2 deletions cmd/account/mgmt/account-unassign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import (
)

func TestAssumeRoleForAccount(t *testing.T) {
viper.Set(awsInternal.ProxyConfigKey, "")
viper.Set(awsInternal.SkipProxyCheckKey, true)
viper.Set(awsInternal.ProxyConfigKey, "a-random-proxy")
mocks := setupDefaultMocks(t, []runtime.Object{})

mockAWSClient := mock.NewMockClient(mocks.mockCtrl)
Expand Down
17 changes: 7 additions & 10 deletions pkg/provider/aws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type AwsClientInput struct {
}

const ProxyConfigKey = "aws_proxy"
const SkipProxyCheckKey = "skip_aws_proxy_check"

// TODO: Add more methods when needed
type Client interface {
Expand Down Expand Up @@ -140,15 +139,13 @@ type AwsClient struct {
func addProxyConfigToSessionOptConfig(config *aws.Config) {
awsProxyUrl := viper.GetString(ProxyConfigKey)
if awsProxyUrl == "" {
_, _ = fmt.Fprintf(os.Stderr, "[WARNING] `%s` not configured. Please add this to your osdctl configuration to ensure traffic is routed though a proxy.\n", ProxyConfigKey)
if skipAwsProxyCheck := viper.GetBool(SkipProxyCheckKey); !skipAwsProxyCheck {
_, _ = fmt.Fprint(os.Stderr, "Please confirm that you would like to continue with [y|N] ")
var input string
_, _ = fmt.Scanln(&input)
if strings.ToLower(input) != "y" {
_, _ = fmt.Fprintln(os.Stderr, "Must enter 'y' to continue; exiting...")
os.Exit(0)
}
_, _ = fmt.Fprintf(os.Stderr, "[ERROR] `%s` not configured. Please add this to your osdctl configuration to ensure traffic is routed though a proxy.\n", ProxyConfigKey)
_, _ = fmt.Fprint(os.Stderr, "Please confirm that you would like to continue with [y|N] ")
var input string
_, _ = fmt.Scanln(&input)
if strings.ToLower(input) != "y" {
_, _ = fmt.Fprintln(os.Stderr, "Must enter 'y' to continue; exiting...")
os.Exit(0)
}
} else {
config.HTTPClient = &http.Client{
Expand Down

0 comments on commit 348936a

Please sign in to comment.