aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpnv1 <pnv@ydb.tech>2022-07-28 13:19:52 +0300
committerpnv1 <pnv@ydb.tech>2022-07-28 13:19:52 +0300
commit33f6e0ab735c2260624e937075b77eb319c07170 (patch)
tree05cc67c4ad23d52c370e5770ccb9b22eba718377
parentb7c253682eafc3daf83c77516aac10b68fea7604 (diff)
downloadydb-33f6e0ab735c2260624e937075b77eb319c07170.tar.gz
Add profile deactivate command to YDB CLI,
-rw-r--r--ydb/public/lib/ydb_cli/commands/ydb_profile.cpp24
-rw-r--r--ydb/public/lib/ydb_cli/commands/ydb_profile.h7
2 files changed, 30 insertions, 1 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_profile.cpp b/ydb/public/lib/ydb_cli/commands/ydb_profile.cpp
index f9f2a16e859..b79e3f89745 100644
--- a/ydb/public/lib/ydb_cli/commands/ydb_profile.cpp
+++ b/ydb/public/lib/ydb_cli/commands/ydb_profile.cpp
@@ -34,6 +34,7 @@ TCommandProfile::TCommandProfile()
AddCommand(std::make_unique<TCommandCreateProfile>());
AddCommand(std::make_unique<TCommandDeleteProfile>());
AddCommand(std::make_unique<TCommandActivateProfile>());
+ AddCommand(std::make_unique<TCommandDeactivateProfile>());
AddCommand(std::make_unique<TCommandListProfiles>());
AddCommand(std::make_unique<TCommandGetProfile>());
}
@@ -506,7 +507,6 @@ void TCommandActivateProfile::Parse(TConfig& config) {
}
int TCommandActivateProfile::Run(TConfig& config) {
- Y_UNUSED(config);
auto profileManager = CreateYdbProfileManager(config.YdbDir);
const auto profileNames = profileManager->ListProfiles();
if (ProfileName) {
@@ -572,6 +572,28 @@ int TCommandActivateProfile::Run(TConfig& config) {
return EXIT_SUCCESS;
}
+TCommandDeactivateProfile::TCommandDeactivateProfile()
+ : TClientCommand("deactivate", {"unset"}, "Deactivate current active configuration profile")
+{}
+
+void TCommandDeactivateProfile::Config(TConfig& config) {
+ TClientCommand::Config(config);
+
+ config.SetFreeArgsMax(0);
+}
+
+int TCommandDeactivateProfile::Run(TConfig& config) {
+ auto profileManager = CreateYdbProfileManager(config.YdbDir);
+ TString currentActiveProfileName = profileManager->GetActiveProfileName();
+ if (currentActiveProfileName) {
+ profileManager->DeactivateProfile();
+ Cout << "Profile \"" << currentActiveProfileName << "\" was deactivated." << Endl;
+ } else {
+ Cout << "There is no profile active. Nothing is done." << Endl;
+ }
+ return EXIT_SUCCESS;
+}
+
TCommandListProfiles::TCommandListProfiles()
: TClientCommand("list", {}, "List configuration profiles")
{}
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_profile.h b/ydb/public/lib/ydb_cli/commands/ydb_profile.h
index 1d556f5585b..395b630203f 100644
--- a/ydb/public/lib/ydb_cli/commands/ydb_profile.h
+++ b/ydb/public/lib/ydb_cli/commands/ydb_profile.h
@@ -58,6 +58,13 @@ private:
TString ProfileName;
};
+class TCommandDeactivateProfile : public TClientCommand {
+public:
+ TCommandDeactivateProfile();
+ virtual void Config(TConfig& config) override;
+ virtual int Run(TConfig& config) override;
+};
+
class TCommandListProfiles : public TClientCommand {
public:
TCommandListProfiles();