From 468431295667d233188363876f4b8d77ae1d4b75 Mon Sep 17 00:00:00 2001 From: Benno van den Berg Date: Mon, 4 Mar 2024 16:41:34 +0100 Subject: [PATCH 1/5] Remove Secret as a generated value and use whatever the user supplies --- src/integrations/pagerduty_receivers.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/integrations/pagerduty_receivers.rs b/src/integrations/pagerduty_receivers.rs index d2facf3..0808b69 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,7 @@ impl GenericKeyValue { .map(|name| name.to_string()) .unwrap_or_else(|| String::from("")), ), - GenericKeyValue::new("Security key:", pagerduty_receiver.security_key), + GenericKeyValue::new("Secret set:", pagerduty_receiver.secret_set.to_string()), GenericKeyValue::new( "Created at:", pagerduty_receiver From 1e145a7b208fb8d60395eb60f4f1e45afbd2a494 Mon Sep 17 00:00:00 2001 From: Benno van den Berg Date: Thu, 21 Mar 2024 16:33:28 +0100 Subject: [PATCH 2/5] Show webhook URL Resolves: FP-3570 --- src/integrations/pagerduty_receivers.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/integrations/pagerduty_receivers.rs b/src/integrations/pagerduty_receivers.rs index 0808b69..21af5b9 100644 --- a/src/integrations/pagerduty_receivers.rs +++ b/src/integrations/pagerduty_receivers.rs @@ -387,6 +387,7 @@ impl GenericKeyValue { .map(|name| name.to_string()) .unwrap_or_else(|| String::from("")), ), + GenericKeyValue::new("Webhook URL:", pagerduty_receiver.webhook_url), GenericKeyValue::new("Secret set:", pagerduty_receiver.secret_set.to_string()), GenericKeyValue::new( "Created at:", From 01ee393f43a50ef36fd1d16d3c1c54b03d6e8903 Mon Sep 17 00:00:00 2001 From: Benno van den Berg Date: Fri, 5 Apr 2024 15:25:44 +0200 Subject: [PATCH 3/5] Update pagerduty_webhook_handling branch for fiberplane --- Cargo.lock | 14 +++++++------- Cargo.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 839ed76..4153989 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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" 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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" 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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" 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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" 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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" 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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" 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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" dependencies = [ "base64uuid", "fiberplane-models", diff --git a/Cargo.toml b/Cargo.toml index 4faa292..7fd386e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,6 +87,6 @@ vergen = { version = "8.0.0", features = [ ] } [patch.crates-io] -fiberplane = { git = "ssh://git@github.com/fiberplane/fiberplane.git", branch = "main" } +fiberplane = { git = "ssh://git@github.com/fiberplane/fiberplane.git", branch = "pagerduty_webhook_handling" } #fp-bindgen-support = { git = "ssh://git@github.com/fiberplane/fp-bindgen.git", branch = "release-3.0.0" } #fp-bindgen-macros = { git = "ssh://git@github.com/fiberplane/fp-bindgen.git", branch = "release-3.0.0" } From 2c18bd8153af6f545b556fb63b644aef0ea437d1 Mon Sep 17 00:00:00 2001 From: Benno van den Berg Date: Tue, 9 Apr 2024 16:01:02 +0200 Subject: [PATCH 4/5] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 4e3dc7216342de5f0ad9727af357c59f52a70090 Mon Sep 17 00:00:00 2001 From: Benno van den Berg Date: Tue, 9 Apr 2024 16:01:20 +0200 Subject: [PATCH 5/5] Back to main --- Cargo.lock | 14 +++++++------- Cargo.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4153989..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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" +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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" +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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" +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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" +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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" +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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" +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=pagerduty_webhook_handling#ba373be4137f3050244999f4c97a98c5895d12fb" +source = "git+ssh://git@github.com/fiberplane/fiberplane.git?branch=main#fb0e921e65ba8f75df682f48390b17ec20eba506" dependencies = [ "base64uuid", "fiberplane-models", diff --git a/Cargo.toml b/Cargo.toml index 7fd386e..4faa292 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,6 +87,6 @@ vergen = { version = "8.0.0", features = [ ] } [patch.crates-io] -fiberplane = { git = "ssh://git@github.com/fiberplane/fiberplane.git", branch = "pagerduty_webhook_handling" } +fiberplane = { git = "ssh://git@github.com/fiberplane/fiberplane.git", branch = "main" } #fp-bindgen-support = { git = "ssh://git@github.com/fiberplane/fp-bindgen.git", branch = "release-3.0.0" } #fp-bindgen-macros = { git = "ssh://git@github.com/fiberplane/fp-bindgen.git", branch = "release-3.0.0" }