Skip to content
361 changes: 360 additions & 1 deletion README.md

Large diffs are not rendered by default.

300 changes: 285 additions & 15 deletions src/cli/pact_broker/main.rs

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions src/cli/pact_broker/main/branches/delete_branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use crate::cli::pact_broker::main::{
HALClient, PactBrokerError,
utils::{
delete_templated_broker_relation, get_auth, get_broker_relation, get_broker_url,
get_ssl_options,
get_custom_headers, get_ssl_options,
},
};

pub fn delete_branch(args: &clap::ArgMatches) -> Result<String, PactBrokerError> {
let broker_url = get_broker_url(args).trim_end_matches('/').to_string();
let auth = get_auth(args);
let custom_headers = get_custom_headers(args);
let ssl_options = get_ssl_options(args);

let branch_name = args.get_one::<String>("branch").unwrap();
Expand All @@ -22,8 +23,12 @@ pub fn delete_branch(args: &clap::ArgMatches) -> Result<String, PactBrokerError>
.unwrap_or(true);

let res = tokio::runtime::Runtime::new().unwrap().block_on(async {
let hal_client: HALClient =
HALClient::with_url(&broker_url, Some(auth.clone()), ssl_options.clone());
let hal_client: HALClient = HALClient::with_url(
&broker_url,
Some(auth.clone()),
ssl_options.clone(),
custom_headers.clone(),
);
let pb_branch_href_path = get_broker_relation(
hal_client.clone(),
"pb:pacticipant-branch".to_string(),
Expand Down
21 changes: 15 additions & 6 deletions src/cli/pact_broker/main/can_i_deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use tracing::debug;

use crate::cli::{
pact_broker::main::{
HALClient, PactBrokerError, process_notices, Notice, utils::{get_auth, get_broker_url, get_ssl_options}
HALClient, Notice, PactBrokerError, process_notices,
utils::{get_auth, get_broker_url, get_custom_headers, get_ssl_options},
},
utils,
};
Expand Down Expand Up @@ -144,11 +145,16 @@ pub fn can_i_deploy(
let dry_run = args.get_flag("dry-run");
let broker_url = get_broker_url(args).trim_end_matches('/').to_string();
let auth = get_auth(args);
let custom_headers = get_custom_headers(args);
let ssl_options = get_ssl_options(args);

tokio::runtime::Runtime::new().unwrap().block_on(async {
let hal_client: HALClient =
HALClient::with_url(&broker_url, Some(auth.clone()), ssl_options.clone());
let hal_client: HALClient = HALClient::with_url(
&broker_url,
Some(auth.clone()),
ssl_options.clone(),
custom_headers.clone(),
);

// Build matrix_href_path using selectors
let mut matrix_href_path = String::from("/matrix?");
Expand Down Expand Up @@ -357,7 +363,10 @@ pub fn can_i_deploy(
}
Err(err) => {
match &err {
crate::cli::pact_broker::main::PactBrokerError::ValidationErrorWithNotices(messages, notices) => {
crate::cli::pact_broker::main::PactBrokerError::ValidationErrorWithNotices(
messages,
notices,
) => {
println!("❌ Can-i-deploy command failed:");
for message in messages {
println!(" {}", message);
Expand All @@ -366,12 +375,12 @@ pub fn can_i_deploy(
println!("\nDetails:");
process_notices(notices);
}
},
}
_ => {
println!("❌ {}", err.to_string());
}
}
return Err(err)
return Err(err);
}
}
})
Expand Down
5 changes: 3 additions & 2 deletions src/cli/pact_broker/main/deployments/record_deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde_json::{Value, json};
use crate::cli::{
pact_broker::main::{
HALClient, PactBrokerError,
utils::{get_auth, get_broker_url, get_ssl_options},
utils::{get_auth, get_broker_url, get_custom_headers, get_ssl_options},
},
utils,
};
Expand All @@ -16,9 +16,10 @@ pub fn record_deployment(args: &clap::ArgMatches) -> Result<String, PactBrokerEr
let application_instance = args.get_one::<String>("application-instance");
let broker_url = get_broker_url(args).trim_end_matches('/').to_string();
let auth = get_auth(args);
let custom_headers = get_custom_headers(args);
let ssl_options = get_ssl_options(args);
tokio::runtime::Runtime::new().unwrap().block_on(async {
let hal_client: HALClient = HALClient::with_url(&broker_url, Some(auth.clone()), ssl_options.clone());
let hal_client: HALClient = HALClient::with_url(&broker_url, Some(auth.clone()), ssl_options.clone(), custom_headers.clone());

let res = hal_client.clone()
.fetch(
Expand Down
5 changes: 3 additions & 2 deletions src/cli/pact_broker/main/deployments/record_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde_json::{Value, json};
use crate::cli::{
pact_broker::main::{
HALClient, PactBrokerError,
utils::{get_auth, get_broker_url, get_ssl_options},
utils::{get_auth, get_broker_url, get_custom_headers, get_ssl_options},
},
utils,
};
Expand All @@ -22,9 +22,10 @@ pub fn record_release(args: &clap::ArgMatches) -> Result<String, PactBrokerError
let environment = args.get_one::<String>("environment");
let broker_url = get_broker_url(args).trim_end_matches('/').to_string();
let auth = get_auth(args);
let custom_headers = get_custom_headers(args);
let ssl_options = get_ssl_options(args);
tokio::runtime::Runtime::new().unwrap().block_on(async {
let hal_client: HALClient = HALClient::with_url(&broker_url, Some(auth.clone()),ssl_options.clone());
let hal_client: HALClient = HALClient::with_url(&broker_url, Some(auth.clone()),ssl_options.clone(), custom_headers.clone());
// todo add trim_end_matches to broker url arg parse
let res = hal_client.clone()
.fetch(
Expand Down
5 changes: 3 additions & 2 deletions src/cli/pact_broker/main/deployments/record_support_ended.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde_json::json;
use crate::cli::{
pact_broker::main::{
HALClient, PactBrokerError,
utils::{get_auth, get_broker_url, get_ssl_options},
utils::{get_auth, get_broker_url, get_custom_headers, get_ssl_options},
},
utils,
};
Expand All @@ -30,10 +30,11 @@ pub fn record_support_ended(args: &clap::ArgMatches) -> Result<String, PactBroke
let version = args.get_one::<String>("version");
let broker_url = get_broker_url(args).trim_end_matches('/').to_string();
let auth = get_auth(args);
let custom_headers = get_custom_headers(args);
let ssl_options = get_ssl_options(args);

tokio::runtime::Runtime::new().unwrap().block_on(async {
let hal_client: HALClient = HALClient::with_url(&broker_url, Some(auth.clone()),ssl_options.clone());
let hal_client: HALClient = HALClient::with_url(&broker_url, Some(auth.clone()),ssl_options.clone(), custom_headers.clone());


let res = hal_client.clone()
Expand Down
6 changes: 4 additions & 2 deletions src/cli/pact_broker/main/deployments/record_undeployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::cli::{
pact_broker::main::{
HALClient, PactBrokerError,
utils::{
follow_broker_relation, get_auth, get_broker_relation, get_broker_url, get_ssl_options,
follow_broker_relation, get_auth, get_broker_relation, get_broker_url,
get_custom_headers, get_ssl_options,
},
},
utils,
Expand Down Expand Up @@ -32,10 +33,11 @@ pub fn record_undeployment(args: &clap::ArgMatches) -> Result<String, PactBroker
let _application_instance = args.get_one::<String>("application-instance");
let broker_url = get_broker_url(args).trim_end_matches('/').to_string();
let auth = get_auth(args);
let custom_headers = get_custom_headers(args);
let ssl_options = get_ssl_options(args);

tokio::runtime::Runtime::new().unwrap().block_on(async {
let hal_client: HALClient = HALClient::with_url(&broker_url, Some(auth.clone()),ssl_options.clone());
let hal_client: HALClient = HALClient::with_url(&broker_url, Some(auth.clone()),ssl_options.clone(), custom_headers.clone());

#[derive(Debug, serde::Deserialize)]
struct Environment {
Expand Down
13 changes: 10 additions & 3 deletions src/cli/pact_broker/main/environments/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use serde_json::json;
use crate::cli::{
pact_broker::main::{
HALClient, PactBrokerError,
utils::{get_auth, get_broker_relation, get_broker_url, get_ssl_options},
utils::{
get_auth, get_broker_relation, get_broker_url, get_custom_headers, get_ssl_options,
},
},
utils,
};
Expand All @@ -16,11 +18,16 @@ pub fn create_environment(args: &clap::ArgMatches) -> Result<String, PactBrokerE
let contact_email_address = args.get_one::<String>("contact-email-address");
let broker_url = get_broker_url(args).trim_end_matches('/').to_string();
let auth = get_auth(args);
let custom_headers = get_custom_headers(args);
let ssl_options = get_ssl_options(args);

tokio::runtime::Runtime::new().unwrap().block_on(async {
let hal_client: HALClient =
HALClient::with_url(&broker_url, Some(auth.clone()), ssl_options.clone());
let hal_client: HALClient = HALClient::with_url(
&broker_url,
Some(auth.clone()),
ssl_options.clone(),
custom_headers.clone(),
);
let pb_environments_href_path = get_broker_relation(
hal_client.clone(),
"pb:environments".to_string(),
Expand Down
11 changes: 8 additions & 3 deletions src/cli/pact_broker/main/environments/delete.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::cli::{
pact_broker::main::{
HALClient, PactBrokerError,
utils::{get_auth, get_broker_url, get_ssl_options},
utils::{get_auth, get_broker_url, get_custom_headers, get_ssl_options},
},
utils,
};
Expand All @@ -10,10 +10,15 @@ pub fn delete_environment(args: &clap::ArgMatches) -> Result<String, PactBrokerE
let uuid = args.get_one::<String>("uuid").unwrap().to_string();
let broker_url = get_broker_url(args).trim_end_matches('/').to_string();
let auth = get_auth(args);
let custom_headers = get_custom_headers(args);
let ssl_options = get_ssl_options(args);
tokio::runtime::Runtime::new().unwrap().block_on(async {
let hal_client: HALClient =
HALClient::with_url(&broker_url, Some(auth.clone()), ssl_options.clone());
let hal_client: HALClient = HALClient::with_url(
&broker_url,
Some(auth.clone()),
ssl_options.clone(),
custom_headers.clone(),
);
let res = hal_client
.clone()
.fetch(&(broker_url.clone() + "/environments/" + &uuid))
Expand Down
19 changes: 8 additions & 11 deletions src/cli/pact_broker/main/environments/describe.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::cli::{
pact_broker::main::{
HALClient, PactBrokerError,
utils::{get_auth, get_broker_url, get_ssl_options},
utils::{get_auth, get_broker_url, get_custom_headers, get_ssl_options},
},
utils,
};
Expand All @@ -10,11 +10,16 @@ pub fn describe_environment(args: &clap::ArgMatches) -> Result<String, PactBroke
let uuid = args.get_one::<String>("uuid").unwrap().to_string();
let broker_url = get_broker_url(args).trim_end_matches('/').to_string();
let auth = get_auth(args);
let custom_headers = get_custom_headers(args);
let ssl_options = get_ssl_options(args);

tokio::runtime::Runtime::new().unwrap().block_on(async {
let hal_client: HALClient =
HALClient::with_url(&broker_url, Some(auth.clone()), ssl_options.clone());
let hal_client: HALClient = HALClient::with_url(
&broker_url,
Some(auth.clone()),
ssl_options.clone(),
custom_headers.clone(),
);
let res = hal_client
.fetch(&(broker_url + "/environments/" + &uuid))
.await;
Expand Down Expand Up @@ -119,10 +124,6 @@ mod describe_environment_tests {
"displayName": like!("existing display name"),
"production": like!(true),
"createdAt": like!("2024-06-01T12:00:00Z"),
"contacts": each_like!({
"name": like!("Contact Name"),
"email": like!("contact@example.com")
}, min = 1)
}));
i
})
Expand Down Expand Up @@ -159,10 +160,6 @@ mod describe_environment_tests {
"displayName": like!("existing display name"),
"production": like!(true),
"createdAt": like!("2024-06-01T12:00:00Z"),
"contacts": each_like!({
"name": like!("Contact Name"),
"email": like!("contact@example.com")
}, min =1)
}));
i
})
Expand Down
12 changes: 9 additions & 3 deletions src/cli/pact_broker/main/environments/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use crate::cli::{
pact_broker::main::{
HALClient, PactBrokerError,
utils::{
follow_broker_relation, get_auth, get_broker_relation, get_broker_url, get_ssl_options,
follow_broker_relation, get_auth, get_broker_relation, get_broker_url,
get_custom_headers, get_ssl_options,
},
},
utils,
Expand All @@ -13,10 +14,15 @@ use comfy_table::presets::UTF8_FULL;
pub fn list_environments(args: &clap::ArgMatches) -> Result<String, PactBrokerError> {
let broker_url = get_broker_url(args).trim_end_matches('/').to_string();
let auth = get_auth(args);
let custom_headers = get_custom_headers(args);
let ssl_options = get_ssl_options(args);
tokio::runtime::Runtime::new().unwrap().block_on(async {
let hal_client: HALClient =
HALClient::with_url(&broker_url, Some(auth.clone()), ssl_options.clone());
let hal_client: HALClient = HALClient::with_url(
&broker_url,
Some(auth.clone()),
ssl_options.clone(),
custom_headers.clone(),
);
let pb_environments_href_path = get_broker_relation(
hal_client.clone(),
"pb:environments".to_string(),
Expand Down
11 changes: 8 additions & 3 deletions src/cli/pact_broker/main/environments/update.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::cli::{
pact_broker::main::{
HALClient, PactBrokerError,
utils::{get_auth, get_broker_url, get_ssl_options},
utils::{get_auth, get_broker_url, get_custom_headers, get_ssl_options},
},
utils,
};
Expand All @@ -18,11 +18,16 @@ pub fn update_environment(args: &clap::ArgMatches) -> Result<String, PactBrokerE
let contact_email_address = args.get_one::<String>("contact-email-address");
let broker_url = get_broker_url(args).trim_end_matches('/').to_string();
let auth = get_auth(args);
let custom_headers = get_custom_headers(args);
let ssl_options = get_ssl_options(args);
let environments_href = format!("{}/environments/{}", broker_url, uuid.clone());
tokio::runtime::Runtime::new().unwrap().block_on(async {
let hal_client: HALClient =
HALClient::with_url(&broker_url, Some(auth.clone()), ssl_options.clone());
let hal_client: HALClient = HALClient::with_url(
&broker_url,
Some(auth.clone()),
ssl_options.clone(),
custom_headers.clone(),
);

// check if the uuid url exists, if not return an error, otherwise continue

Expand Down
Loading