Skip to content

Commit 7c5b2e0

Browse files
Closes #38
1 parent 068e637 commit 7c5b2e0

File tree

5 files changed

+44
-2
lines changed

5 files changed

+44
-2
lines changed

src/cli.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pub fn parser() -> Command {
253253
])
254254
}
255255

256-
fn list_subcommands() -> [Command; 17] {
256+
fn list_subcommands() -> [Command; 18] {
257257
// duplicate this very common global argument so that
258258
// it can be passed as the end of argument list
259259
let vhost_arg = Arg::new("vhost")
@@ -360,6 +360,12 @@ fn list_subcommands() -> [Command; 17] {
360360
"<bold>Doc guide</bold>: {}",
361361
USER_LIMIT_GUIDE_URL
362362
)),
363+
Command::new("feature_flags")
364+
.long_about("Lists feature flags and their cluster state")
365+
.after_long_help(color_print::cformat!(
366+
"<bold>Doc guide</bold>: {}",
367+
FEATURE_FLAG_GUIDE_URL
368+
)),
363369
Command::new("deprecated_features")
364370
.long_about("Lists all deprecated features")
365371
.after_long_help(color_print::cformat!(

src/commands.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rabbitmq_http_client::requests::EnforcedLimitParams;
2828
use crate::constants::DEFAULT_QUEUE_TYPE;
2929
use rabbitmq_http_client::commons::BindingDestinationType;
3030
use rabbitmq_http_client::commons::QueueType;
31-
use rabbitmq_http_client::responses::Overview;
31+
use rabbitmq_http_client::responses::{FeatureFlagList, Overview};
3232
use rabbitmq_http_client::{password_hashing, requests, responses};
3333

3434
type APIClient<'a> = Client<&'a str, &'a str, &'a str>;
@@ -122,6 +122,10 @@ pub fn list_parameters(
122122
}
123123
}
124124

125+
pub fn list_feature_flags(client: APIClient) -> ClientResult<FeatureFlagList> {
126+
client.list_feature_flags()
127+
}
128+
125129
pub fn list_deprecated_features(
126130
client: APIClient,
127131
) -> ClientResult<responses::DeprecatedFeatureList> {

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ fn dispatch_subcommand(
232232
let result = commands::list_exchanges(client, &vhost);
233233
res_handler.tabular_result(result)
234234
}
235+
("list", "feature_flags") => {
236+
let result = commands::list_feature_flags(client);
237+
res_handler.tabular_result(result.map(|val| val.0))
238+
}
235239
("list", "deprecated_features") => {
236240
let result = commands::list_deprecated_features(client);
237241
res_handler.tabular_result(result.map(|val| val.0))

src/static_urls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub(crate) const BLUE_GREEN_UPGRADE_GUIDE_URL: &str =
3434
pub(crate) const MONITORING_GUIDE_URL: &str = "https://rabbitmq.com/docs/monitoring";
3535
pub(crate) const HEALTH_CHECK_GUIDE_URL: &str =
3636
"https://rabbitmq.com/docs/monitoring#health-checks";
37+
pub(crate) const FEATURE_FLAG_GUIDE_URL: &str = "https://rabbitmq.com/docs/feature-flags";
3738
pub(crate) const DEPRECATED_FEATURE_GUIDE_URL: &str =
3839
"https://rabbitmq.com/docs/deprecated-features";
3940
pub(crate) const ACCESS_CONTROL_GUIDE_URL: &str = "https://rabbitmq.com/docs/access-control";

tests/list_feature_flag_tests.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (C) 2023-2024 RabbitMQ Core Team ([email protected])
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
use predicates::prelude::*;
16+
17+
mod test_helpers;
18+
use crate::test_helpers::*;
19+
20+
#[test]
21+
fn test_list_feature_flags() -> Result<(), Box<dyn std::error::Error>> {
22+
run_succeeds(["list", "feature_flags"]).stdout(
23+
predicate::str::contains("rabbitmq_4.0.0").and(predicate::str::contains("khepri_db")),
24+
);
25+
26+
Ok(())
27+
}

0 commit comments

Comments
 (0)