Skip to content

Commit

Permalink
Closes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Dec 29, 2024
1 parent 068e637 commit 7c5b2e0
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub fn parser() -> Command {
])
}

fn list_subcommands() -> [Command; 17] {
fn list_subcommands() -> [Command; 18] {
// duplicate this very common global argument so that
// it can be passed as the end of argument list
let vhost_arg = Arg::new("vhost")
Expand Down Expand Up @@ -360,6 +360,12 @@ fn list_subcommands() -> [Command; 17] {
"<bold>Doc guide</bold>: {}",
USER_LIMIT_GUIDE_URL
)),
Command::new("feature_flags")
.long_about("Lists feature flags and their cluster state")
.after_long_help(color_print::cformat!(
"<bold>Doc guide</bold>: {}",
FEATURE_FLAG_GUIDE_URL
)),
Command::new("deprecated_features")
.long_about("Lists all deprecated features")
.after_long_help(color_print::cformat!(
Expand Down
6 changes: 5 additions & 1 deletion src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use rabbitmq_http_client::requests::EnforcedLimitParams;
use crate::constants::DEFAULT_QUEUE_TYPE;
use rabbitmq_http_client::commons::BindingDestinationType;
use rabbitmq_http_client::commons::QueueType;
use rabbitmq_http_client::responses::Overview;
use rabbitmq_http_client::responses::{FeatureFlagList, Overview};
use rabbitmq_http_client::{password_hashing, requests, responses};

type APIClient<'a> = Client<&'a str, &'a str, &'a str>;
Expand Down Expand Up @@ -122,6 +122,10 @@ pub fn list_parameters(
}
}

pub fn list_feature_flags(client: APIClient) -> ClientResult<FeatureFlagList> {
client.list_feature_flags()
}

pub fn list_deprecated_features(
client: APIClient,
) -> ClientResult<responses::DeprecatedFeatureList> {
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ fn dispatch_subcommand(
let result = commands::list_exchanges(client, &vhost);
res_handler.tabular_result(result)
}
("list", "feature_flags") => {
let result = commands::list_feature_flags(client);
res_handler.tabular_result(result.map(|val| val.0))
}
("list", "deprecated_features") => {
let result = commands::list_deprecated_features(client);
res_handler.tabular_result(result.map(|val| val.0))
Expand Down
1 change: 1 addition & 0 deletions src/static_urls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub(crate) const BLUE_GREEN_UPGRADE_GUIDE_URL: &str =
pub(crate) const MONITORING_GUIDE_URL: &str = "https://rabbitmq.com/docs/monitoring";
pub(crate) const HEALTH_CHECK_GUIDE_URL: &str =
"https://rabbitmq.com/docs/monitoring#health-checks";
pub(crate) const FEATURE_FLAG_GUIDE_URL: &str = "https://rabbitmq.com/docs/feature-flags";
pub(crate) const DEPRECATED_FEATURE_GUIDE_URL: &str =
"https://rabbitmq.com/docs/deprecated-features";
pub(crate) const ACCESS_CONTROL_GUIDE_URL: &str = "https://rabbitmq.com/docs/access-control";
Expand Down
27 changes: 27 additions & 0 deletions tests/list_feature_flag_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (C) 2023-2024 RabbitMQ Core Team (teamrabbitmq@gmail.com)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use predicates::prelude::*;

mod test_helpers;
use crate::test_helpers::*;

#[test]
fn test_list_feature_flags() -> Result<(), Box<dyn std::error::Error>> {
run_succeeds(["list", "feature_flags"]).stdout(
predicate::str::contains("rabbitmq_4.0.0").and(predicate::str::contains("khepri_db")),
);

Ok(())
}

0 comments on commit 7c5b2e0

Please sign in to comment.