Skip to content

Commit 300b91f

Browse files
Update bito-cra.ps1
1 parent 5c04d63 commit 300b91f

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

cra-scripts/bito-cra.ps1

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ function Validate-Env {
9393
}
9494
}
9595

96+
# Function to validate a review_comments vallue i.e. 1 mapped to "FULLPOST" or 2 mapped to "INLINE"
97+
function Validate-ReviewComments {
98+
param($reviewcomments_val)
99+
100+
# Check if the provided value is either "1" or "2"
101+
if ($reviewcomments_val -ne "1" -and $reviewcomments_val -ne "2") {
102+
Write-Host "Invalid review comments value. Please enter either 1 or 2."
103+
exit 1
104+
}
105+
106+
if ($reviewcomments_val -eq "1") {
107+
return "FULLPOST"
108+
}
109+
110+
if ($reviewcomments_val -eq "2") {
111+
return "INLINE"
112+
}
113+
}
114+
96115
# Function to display URL using IP address and port
97116
# Run docker ps -l command and store the output
98117
function Display-DockerUrl {
@@ -332,14 +351,17 @@ $required_params_cli = @(
332351
)
333352

334353
$optional_params_cli = @(
354+
"review_comments",
335355
"static_analysis",
356+
"static_analysis_tool",
336357
"dependency_check",
337358
"dependency_check.snyk_auth_token",
338359
"cra_version",
339360
"env",
340361
"cli_path",
341362
"output_path"
342363
"git.domain"
364+
"code_context"
343365
)
344366

345367
# Parameters that are required/optional in mode server
@@ -352,14 +374,17 @@ $optional_params_server = @(
352374
"git.provider",
353375
"git.access_token",
354376
"bito_cli.bito.access_key",
377+
"review_comments",
355378
"static_analysis",
379+
"static_analysis_tool",
356380
"dependency_check",
357381
"dependency_check.snyk_auth_token",
358382
"server_port",
359383
"cra_version"
360384
"env"
361385
"cli_path"
362386
"git.domain"
387+
"code_context"
363388
)
364389

365390
$bee_params = @(
@@ -427,7 +452,7 @@ foreach ($param in $required_params) {
427452
foreach ($param in $optional_params) {
428453
if ($param -eq "dependency_check.snyk_auth_token" -and $props["dependency_check"] -eq "True") {
429454
Ask-For-Param $param $false
430-
} elseif ($param -ne "dependency_check.snyk_auth_token" -and $param -ne "env" -and $param -ne "cli_path" -and $param -ne "output_path" -and $param -ne "git.domain") {
455+
} elseif ($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 "git.domain") {
431456
Ask-For-Param $param $false
432457
}
433458
}
@@ -451,12 +476,18 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
451476
} elseif ($param -eq "static_analysis") {
452477
$validated_boolean = Validate-Boolean $props[$param]
453478
$docker_cmd += " --static_analysis.fb_infer.enabled=$validated_boolean"
479+
} elseif ($param -eq "static_analysis_tool") {
480+
$docker_cmd += " --$param=$($props[$param])"
454481
} elseif ($param -eq "dependency_check") {
455482
$validated_boolean = Validate-Boolean $props[$param]
456483
$docker_cmd += " --dependency_check.enabled=$validated_boolean"
457484
} elseif ($param -eq "code_feedback") {
458485
$validated_boolean = Validate-Boolean $props[$param]
459486
$docker_cmd += " --$param=$validated_boolean"
487+
} elseif ($param -eq "code_context") {
488+
#validate the code context boolean value
489+
$validated_boolean = Validate-Boolean $props[$param]
490+
$docker_cmd += " --$param=$validated_boolean"
460491
} elseif ($param -eq "mode") {
461492
Validate-Mode $props[$param]
462493
$docker_cmd += " --$param=$($props[$param])"
@@ -474,6 +505,9 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
474505
$docker_cmd += " --$param=/output_path"
475506
}
476507
}
508+
} elseif ($param -eq "review_comments") {
509+
$review_comments = Validate-ReviewComments $props[$param]
510+
$docker_cmd += " --$param=$review_comments"
477511
} else {
478512
$docker_cmd += " --$param=$($props[$param])"
479513
}

0 commit comments

Comments
 (0)