diff --git a/CHANGELOG.md b/CHANGELOG.md index b394e33..8c40010 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format of this file is based on [Keep a Changelog](https://keepachangelog.co ### Added - Added `workspaces integrations list` command (#284) +- Allow user to specify the secret instead of receiving it from the api (#288) ## [2.23.0] - 2024-03-01 diff --git a/Cargo.lock b/Cargo.lock index 839ed76..897fc22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64uuid" version = "1.1.0" -source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#d60cce161e2d375e0c25fff7a51bfa609a3c0087" +source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#fb0e921e65ba8f75df682f48390b17ec20eba506" dependencies = [ "base64 0.13.1", "serde", @@ -969,7 +969,7 @@ checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "fiberplane" version = "1.0.0-beta.14" -source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#d60cce161e2d375e0c25fff7a51bfa609a3c0087" +source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#fb0e921e65ba8f75df682f48390b17ec20eba506" dependencies = [ "base64uuid", "fiberplane-api-client", @@ -982,7 +982,7 @@ dependencies = [ [[package]] name = "fiberplane-api-client" version = "1.0.0-beta.13" -source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#d60cce161e2d375e0c25fff7a51bfa609a3c0087" +source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#fb0e921e65ba8f75df682f48390b17ec20eba506" dependencies = [ "anyhow", "base64uuid", @@ -999,7 +999,7 @@ dependencies = [ [[package]] name = "fiberplane-markdown" version = "1.0.0-beta.13" -source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#d60cce161e2d375e0c25fff7a51bfa609a3c0087" +source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#fb0e921e65ba8f75df682f48390b17ec20eba506" dependencies = [ "fiberplane-models", "pulldown-cmark", @@ -1011,7 +1011,7 @@ dependencies = [ [[package]] name = "fiberplane-models" version = "1.0.0-beta.13" -source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#d60cce161e2d375e0c25fff7a51bfa609a3c0087" +source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#fb0e921e65ba8f75df682f48390b17ec20eba506" dependencies = [ "base64 0.13.1", "base64uuid", @@ -1035,7 +1035,7 @@ dependencies = [ [[package]] name = "fiberplane-provider-runtime" version = "2.0.0-beta.13" -source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#d60cce161e2d375e0c25fff7a51bfa609a3c0087" +source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#fb0e921e65ba8f75df682f48390b17ec20eba506" dependencies = [ "bytes", "fiberplane-models", @@ -1055,7 +1055,7 @@ dependencies = [ [[package]] name = "fiberplane-templates" version = "1.0.0-beta.14" -source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#d60cce161e2d375e0c25fff7a51bfa609a3c0087" +source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#fb0e921e65ba8f75df682f48390b17ec20eba506" dependencies = [ "base64uuid", "fiberplane-models", diff --git a/src/integrations/pagerduty_receivers.rs b/src/integrations/pagerduty_receivers.rs index d2facf3..21af5b9 100644 --- a/src/integrations/pagerduty_receivers.rs +++ b/src/integrations/pagerduty_receivers.rs @@ -79,6 +79,11 @@ struct CreateArgs { #[clap(long, short)] incident_created_template: Option, + /// An optional secret to set on the PagerDuty receiver. If this is set, + /// then any incoming webhook will be verified against this secret. + #[clap(long)] + secret: Option, + /// Output of the webhooks #[clap(long, short, default_value = "table", value_enum)] output: PagerDutyWebhookOutput, @@ -106,6 +111,7 @@ async fn handle_create(args: CreateArgs) -> Result<()> { let new_pagerduty_receiver = NewPagerDutyReceiver::builder() .incident_created_template_name(args.incident_created_template) + .secret(args.secret) .build(); let pagerduty_receiver = client .pagerduty_receiver_create(workspace_id, &name, new_pagerduty_receiver) @@ -178,8 +184,14 @@ struct UpdateArgs { #[clap(long, env, conflicts_with = "incident_creation_template")] clear_incident_creation_template: bool, - #[clap(long, short)] - regenerate_security_key: bool, + /// An optional secret to set on the PagerDuty receiver. If this is set, + /// then any incoming webhook will be verified against this secret + #[clap(long, env, conflicts_with = "clear_secret")] + secret: Option, + + /// Clear the secret on the PagerDuty receiver. + #[clap(long, env, conflicts_with = "secret")] + clear_secret: bool, /// Output of the webhooks #[clap(long, short, default_value = "table", value_enum)] @@ -211,9 +223,11 @@ async fn handle_update(args: UpdateArgs) -> Result<()> { args.incident_creation_template, ); + let secret = clear_or_update(args.clear_secret, args.secret); + let update_pagerduty_receiver = UpdatePagerDutyReceiver::builder() .incident_created_template_name(incident_created_template_name) - .regenerate_security_key(args.regenerate_security_key) + .secret(secret) .build(); let pagerduty_receiver = client @@ -373,7 +387,8 @@ impl GenericKeyValue { .map(|name| name.to_string()) .unwrap_or_else(|| String::from("")), ), - GenericKeyValue::new("Security key:", pagerduty_receiver.security_key), + GenericKeyValue::new("Webhook URL:", pagerduty_receiver.webhook_url), + GenericKeyValue::new("Secret set:", pagerduty_receiver.secret_set.to_string()), GenericKeyValue::new( "Created at:", pagerduty_receiver