Skip to main content

stackless_integrations/providers/sentry/
seer.rs

1//! `sentry/seer` integration.
2
3use std::collections::BTreeMap;
4
5use serde::Serialize;
6use stackless_stripe_projects::catalog::verify::CatalogService;
7use stackless_stripe_projects::provision::ProvisionContext;
8
9use super::FamilyResource;
10use crate::error::IntegrationError;
11use crate::hostable::{ConfigScope, Hostable, IntegrationHosting};
12
13pub const RESOURCE_KIND: &str = "integration-sentry-seer";
14
15#[derive(Debug, Serialize)]
16pub struct SentrySeerConfig {}
17
18impl CatalogService for SentrySeerConfig {
19    const REFERENCE: &'static str = "sentry/seer";
20}
21
22#[derive(Debug)]
23pub struct SentrySeer;
24
25impl Hostable for SentrySeer {
26    const PROVIDER: &'static str = "sentry-seer";
27    const HOSTING: IntegrationHosting = IntegrationHosting::Managed;
28    const CONFIG_SCOPE: ConfigScope = ConfigScope::GlobalOnly;
29    const RESOURCE_KIND: &'static str = RESOURCE_KIND;
30    const OUTPUTS: &'static [&'static str] = &["auth_token"];
31}
32
33impl FamilyResource for SentrySeer {
34    type Config = SentrySeerConfig;
35    const PROVIDER_PREFIX: &'static str = "SENTRY";
36    // Provisional until pinned by `mise run discover sentry/seer`.
37    const OUTPUT_FIELDS: &'static [(&'static str, &'static str, bool)] =
38        &[("AUTH_TOKEN", "auth_token", true)];
39
40    fn build_config(ctx: &ProvisionContext<'_>) -> Result<SentrySeerConfig, IntegrationError> {
41        let _ = super::integration_config(ctx)?;
42        Ok(SentrySeerConfig {})
43    }
44}
45
46pub fn validate_config(
47    name: &str,
48    config: &BTreeMap<String, toml::Value>,
49) -> Result<(), IntegrationError> {
50    let _ = (name, config);
51    Ok(())
52}
53
54#[cfg(test)]
55mod tests {
56    use super::*;
57    use crate::ProviderOps;
58    use crate::resource::ResourcePayload;
59    use stackless_core::def::StackDef;
60    use stackless_stripe_projects::stripe::StripeProjects;
61    use stackless_stripe_projects::test_support;
62
63    #[test]
64    fn config_matches_catalog() {
65        const FIXTURE: &str = include_str!(concat!(
66            env!("CARGO_MANIFEST_DIR"),
67            "/../stackless-stripe-projects/tests/fixtures/catalog.json"
68        ));
69        let catalog = stackless_stripe_projects::Catalog::from_json_envelope(FIXTURE).unwrap();
70        let failures = stackless_stripe_projects::verify_service(&catalog, &SentrySeerConfig {});
71        assert!(
72            failures.is_empty(),
73            "sentry/seer catalog gaps:\n{}",
74            failures.join("\n")
75        );
76    }
77
78    const CATALOG_ENVELOPE: &str = r##"{"ok":true,"command":"projects catalog","data":{"last_updated":"2026-07-11T00:00:00Z","services":[{"id":"prvsvc_seer","object":"v2.provisioning.provider_service_detail","provider_id":"prvdr_sentry","provider_name":"Sentry","service_id":"seer","categories":["database"],"kind":"deployable","scope":"project","availability":"available","development":false,"livemode":true,"pricing":{"type":"component"},"configuration_schema":{"type":"object","required":[],"additionalProperties":false,"properties":{}}}]}}"##;
79
80    fn test_def() -> StackDef {
81        StackDef::parse(
82            r#"
83[stack]
84name = "atto"
85[stack.projects.stripe]
86project = "project_1"
87[integrations.res]
88provider = "sentry-seer"
89[services.api]
90source = { repo = "r", ref = "main" }
91env = { OUT = "${integrations.res.auth_token}" }
92health = { path = "/health" }
93[services.api.local]
94run = "true"
95"#,
96        )
97        .unwrap()
98    }
99
100    #[tokio::test]
101    async fn provision_records_outputs() {
102        let runner = test_support::provision_script(
103            CATALOG_ENVELOPE,
104            serde_json::json!({"SENTRY_AUTH_TOKEN": "val_auth_token"}),
105            0,
106        );
107        let dir = tempfile::tempdir().unwrap();
108        std::fs::write(
109            dir.path().join("stackless.toml"),
110            "[stack]\nname=\"atto\"\n",
111        )
112        .unwrap();
113        let stripe = StripeProjects::new(&runner, dir.path());
114
115        let resource = SentrySeer
116            .provision(
117                &stripe.as_dyn(),
118                &test_def(),
119                dir.path(),
120                "demo",
121                "res",
122                "local",
123                false,
124            )
125            .await
126            .unwrap();
127        assert_eq!(resource.resource_kind, "integration-sentry-seer");
128        let payload: ResourcePayload = serde_json::from_str(&resource.payload).unwrap();
129        assert_eq!(payload.outputs["auth_token"], "val_auth_token");
130    }
131}