Skip to content

Commit

Permalink
add new flag to ignore proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrompflopes committed Sep 6, 2023
1 parent ea7596a commit eb5460e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ func NewAstCLI(
_ = viper.BindPFlag(params.BaseAuthURIKey, rootCmd.PersistentFlags().Lookup(params.BaseAuthURIFlag))
_ = viper.BindPFlag(params.AstAPIKey, rootCmd.PersistentFlags().Lookup(params.AstAPIKeyFlag))
_ = viper.BindPFlag(params.AgentNameKey, rootCmd.PersistentFlags().Lookup(params.AgentFlag))
_ = viper.BindPFlag(params.IgnoreProxyKey, rootCmd.PersistentFlags().Lookup(params.IgnoreProxyFlag))
// Key here is the actual flag since it doesn't use an environment variable
_ = viper.BindPFlag(params.DebugFlag, rootCmd.PersistentFlags().Lookup(params.DebugFlag))
_ = viper.BindPFlag(params.InsecureFlag, rootCmd.PersistentFlags().Lookup(params.InsecureFlag))
_ = viper.BindPFlag(params.RetryFlag, rootCmd.PersistentFlags().Lookup(params.RetryFlag))
_ = viper.BindPFlag(params.RetryDelayFlag, rootCmd.PersistentFlags().Lookup(params.RetryDelayFlag))
_ = viper.BindPFlag(params.ApikeyOverrideFlag, rootCmd.PersistentFlags().Lookup(params.ApikeyOverrideFlag))
_ = viper.BindPFlag(params.IgnoreProxyFlag, rootCmd.PersistentFlags().Lookup(params.IgnoreProxyFlag))

// Set help func
rootCmd.SetHelpFunc(
Expand Down
1 change: 1 addition & 0 deletions internal/params/binds.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var EnvVarsBinds = []struct {
{ProxyDomainKey, ProxyDomainEnv, ""},
{BaseAuthURIKey, BaseAuthURIEnv, ""},
{AstAPIKey, AstAPIKeyEnv, ""},
{IgnoreProxyKey, IgnoreProxyEnv, ""},
{AgentNameKey, AgentNameEnv, "ASTCLI"},
{CodeBashingPathKey, ScansPathEnv, "api/codebashing/lessons"},
{ScansPathKey, ScansPathEnv, "api/scans"},
Expand Down
1 change: 1 addition & 0 deletions internal/params/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ const (
FeatureFlagsEnv = "CX_FEATURE_FLAGS_PATH"
UploadURLEnv = "CX_UPLOAD_URL"
PolicyEvaluationPathEnv = "CX_POLICY_EVALUATION_PATH"
IgnoreProxyEnv = "CX_IGNORE_PROXY"
)
1 change: 1 addition & 0 deletions internal/params/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var (
ScansPathKey = strings.ToLower(ScansPathEnv)
GroupsPathKey = strings.ToLower(GroupsPathEnv)
AgentNameKey = strings.ToLower(AgentNameEnv)
IgnoreProxyKey = strings.ToLower(IgnoreProxyEnv)
CodeBashingPathKey = strings.ToLower(CodeBashingPathEnv)
ProjectsPathKey = strings.ToLower(ProjectsPathEnv)
ResultsPathKey = strings.ToLower(ResultsPathEnv)
Expand Down
2 changes: 1 addition & 1 deletion internal/wrappers/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func setAgentName(req *http.Request) {
func GetClient(timeout uint) *http.Client {
proxyTypeStr := viper.GetString(commonParams.ProxyTypeKey)
proxyStr := viper.GetString(commonParams.ProxyKey)
ignoreProxy := viper.GetBool(commonParams.IgnoreProxyFlag)
ignoreProxy := viper.GetBool(commonParams.IgnoreProxyKey)

if ignoreProxy {
proxyStr = ""
Expand Down

0 comments on commit eb5460e

Please sign in to comment.