Skip to content

Commit

Permalink
ora: simplify consent and mode validation by removing redundant checks
Browse files Browse the repository at this point in the history
Signed-off-by: Palaniappan R <[email protected]>
  • Loading branch information
palaniappan-r committed Jan 31, 2025
1 parent 1ac8681 commit 07d0e2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
9 changes: 2 additions & 7 deletions src/ora/src/Ora.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,7 @@ void Ora::setConsent(const char* consent)
std::string consentFilePath = localDirPath + "/orassistant_consent.txt";
std::ofstream consentFile(consentFilePath);

// check if consent is y or n
if (std::string(consent) != "y" && std::string(consent) != "n") {
logger_->error(
utl::ORA, 115, "{} : Invalid consent value. Use 'y' or 'n'.", consent);
return;
}

// the consent string is validated in Ora.i
if (consentFile.is_open()) {
consentFile << "consent: " << consent << "\n";
consentFile << "consent_version: " << consentVersion << "\n";
Expand Down Expand Up @@ -337,6 +331,7 @@ void Ora::setMode(const char* mode)
std::string modeFilePath = localDirPath + "/orassistant_mode.txt";
std::ofstream modeFile(modeFilePath);

// the mode is validated in Ora.i
if (modeFile.is_open()) {
modeFile << mode;
modeFile.close();
Expand Down
13 changes: 7 additions & 6 deletions src/ora/src/Ora.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@ proc askbot { args } {
ora::askbot [lindex $args 0]
}


proc ora_init {arg1 {arg2 ""}} {
if {$arg1 ni {"local" "cloud"}} {
puts "ERROR: Invalid mode '$arg1'. Use 'local' or 'cloud'."
return;
return
}

ora::set_mode $arg1

if {$arg1 eq "cloud"} {
if {$arg2 ni {"y" "n"}} {
puts "ERROR: Invalid consent value '$arg2'. Use 'y' or 'n'."
return
}
ora::set_consent $arg2
} elseif {$arg1 eq "local"} {
ora::set_bothost $arg2
} else {
puts "Invalid mode: $arg1"
}
}
}

0 comments on commit 07d0e2b

Please sign in to comment.