Skip to content

Commit 297f3e0

Browse files
Update bito-cra.ps1
1 parent 28d6df0 commit 297f3e0

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

cra-scripts/bito-cra.ps1

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ function Validate-Boolean {
7474
return $boolean_val
7575
}
7676

77+
# Function to set default suggestion mode
78+
function Validate-Suggestion-Mode {
79+
param($suggestion_mode)
80+
# Convert the input to lowercase
81+
$suggestion_mode = $suggestion_mode.ToLower()
82+
83+
if ($suggestion_mode -eq "comprehensive") {
84+
return $suggestion_mode
85+
}
86+
87+
return "essential"
88+
}
89+
7790
# Function to validate a mode value i.e. cli or server
7891
function Validate-Mode {
7992
param($mode_val)
@@ -414,7 +427,10 @@ $optional_params_cli = @(
414427
"enable_default_branch",
415428
"exclude_branches",
416429
"include_source_branches",
417-
"include_target_branches",
430+
"include_target_branches"
431+
"post_as_request_changes",
432+
"suggestion_mode",
433+
"locale",
418434
"exclude_files",
419435
"exclude_draft_pr",
420436
"dependency_check",
@@ -433,6 +449,7 @@ $optional_params_cli = @(
433449
"custom_rules.region_name"
434450
"custom_rules.bucket_name"
435451
"custom_rules.aes_key"
452+
"support_email"
436453
)
437454

438455
# Parameters that are required/optional in mode server
@@ -456,6 +473,9 @@ $optional_params_server = @(
456473
"exclude_branches",
457474
"include_source_branches",
458475
"include_target_branches",
476+
"post_as_request_changes",
477+
"suggestion_mode",
478+
"locale",
459479
"exclude_files",
460480
"exclude_draft_pr",
461481
"dependency_check",
@@ -474,6 +494,7 @@ $optional_params_server = @(
474494
"custom_rules.bucket_name"
475495
"custom_rules.aes_key"
476496
"output_path"
497+
"support_email"
477498
)
478499

479500
$bee_params = @(
@@ -542,7 +563,7 @@ foreach ($param in $required_params) {
542563
foreach ($param in $optional_params) {
543564
if ($param -eq "dependency_check.snyk_auth_token" -and $props["dependency_check"] -eq "True") {
544565
Ask-For-Param $param $false
545-
} elseif ($param -ne "acceptable_suggestions_enabled" -and $param -ne "dependency_check.snyk_auth_token" -and $param -ne "env" -and $param -ne "cli_path" -and $param -ne "output_path" -and $param -ne "static_analysis_tool" -and $param -ne "linters_feedback" -and $param -ne "secret_scanner_feedback" -and $param -ne "enable_default_branch" -and $param -ne "git.domain" -and $param -ne "review_scope" -and $param -ne "exclude_branches" -and $param -ne "include_source_branches" -and $param -ne "include_target_branches" -and $param -ne "exclude_files" -and $param -ne "exclude_draft_pr" -and $param -ne "cr_event_type" -and $param -ne "posting_to_pr" -and $param -ne "custom_rules.configured_ws_ids" -and $param -ne "custom_rules.aws_access_key_id" -and $param -ne "custom_rules.aws_secret_access_key" -and $param -ne "custom_rules.region_name" -and $param -ne "custom_rules.bucket_name" -and $param -ne "custom_rules.aes_key" -and $param -ne "code_context_config.partial_timeout" -and $param -ne "code_context_config.max_depth" -and $param -ne "code_context_config.kill_timeout_sec") {
566+
} elseif ($param -ne "acceptable_suggestions_enabled" -and $param -ne "dependency_check.snyk_auth_token" -and $param -ne "env" -and $param -ne "cli_path" -and $param -ne "output_path" -and $param -ne "static_analysis_tool" -and $param -ne "linters_feedback" -and $param -ne "secret_scanner_feedback" -and $param -ne "enable_default_branch" -and $param -ne "git.domain" -and $param -ne "review_scope" -and $param -ne "exclude_branches" -and $param -ne "include_source_branches" -and $param -ne "include_target_branches" -and $param -ne "suggestion_mode" -and $param -ne "locale" -and $param -ne "exclude_files" -and $param -ne "exclude_draft_pr" -and $param -ne "cr_event_type" -and $param -ne "posting_to_pr" -and $param -ne "custom_rules.configured_ws_ids" -and $param -ne "custom_rules.aws_access_key_id" -and $param -ne "custom_rules.aws_secret_access_key" -and $param -ne "custom_rules.region_name" -and $param -ne "custom_rules.bucket_name" -and $param -ne "custom_rules.aes_key" -and $param -ne "code_context_config.partial_timeout" -and $param -ne "code_context_config.max_depth" -and $param -ne "code_context_config.kill_timeout_sec" -and $param -ne "support_email" -and $param -ne "post_as_request_changes") {
546567
Ask-For-Param $param $false
547568
}
548569
}
@@ -571,6 +592,9 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
571592
} elseif ($param -eq "linters_feedback") {
572593
$validated_boolean = Validate-Boolean $props[$param]
573594
$docker_cmd += " --$param=$validated_boolean"
595+
} elseif ($param -eq "post_as_request_changes") {
596+
$validated_boolean = Validate-Boolean $props[$param]
597+
$docker_cmd += " --$param=$validated_boolean"
574598
} elseif ($param -eq "secret_scanner_feedback") {
575599
$validated_boolean = Validate-Boolean $props[$param]
576600
$docker_cmd += " --$param=$validated_boolean"
@@ -589,6 +613,11 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
589613
$docker_cmd += " --include_source_branches='$($props[$param])'"
590614
} elseif ($param -eq "include_target_branches") {
591615
$docker_cmd += " --include_target_branches='$($props[$param])'"
616+
} elseif ($param -eq "suggestion_mode") {
617+
$validated_suggestion_mode = Validate-Suggestion-Mode $props[$param]
618+
$docker_cmd += " --suggestion_mode='$validated_suggestion_mode'"
619+
} elseif ($param -eq "locale") {
620+
$docker_cmd += " --locale='$($props[$param])'"
592621
} elseif ($param -eq "exclude_files") {
593622
$docker_cmd += " --exclude_files='$($props[$param])'"
594623
} elseif ($param -eq "exclude_draft_pr") {
@@ -627,8 +656,9 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
627656
$crEventType = ValidateCrEventType $props[$param]
628657
} elseif ($param -eq "posting_to_pr") {
629658
$postingToPr = ValidatePostingToPr $props[$param]
630-
}
631-
else {
659+
} elseif ($param -eq "support_email") {
660+
$docker_cmd += " --support_email='$( $props[$param] )'"
661+
} else {
632662
$docker_cmd += " --$param=$($props[$param])"
633663
}
634664
}

0 commit comments

Comments
 (0)