Skip to main content

drasi_bootstrap_application/
descriptor.rs

1// Copyright 2025 The Drasi Authors.
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//! Plugin descriptor for the Application bootstrap provider.
16
17use drasi_lib::bootstrap::BootstrapProvider;
18use drasi_plugin_sdk::prelude::*;
19use utoipa::OpenApi;
20
21use crate::ApplicationBootstrapProvider;
22
23// ── DTO types ────────────────────────────────────────────────────────────────
24
25/// Empty configuration DTO for the Application bootstrap provider.
26#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, utoipa::ToSchema)]
27#[schema(as = bootstrap::application::ApplicationBootstrapConfig)]
28pub struct ApplicationBootstrapConfigDto {}
29
30// ── Descriptor ───────────────────────────────────────────────────────────────
31
32#[derive(OpenApi)]
33#[openapi(components(schemas(ApplicationBootstrapConfigDto)))]
34struct ApplicationBootstrapSchemas;
35
36/// Plugin descriptor for the Application bootstrap provider.
37pub struct ApplicationBootstrapDescriptor;
38
39#[async_trait]
40impl BootstrapPluginDescriptor for ApplicationBootstrapDescriptor {
41    fn kind(&self) -> &str {
42        "application"
43    }
44
45    fn config_version(&self) -> &str {
46        "1.0.0"
47    }
48
49    fn config_schema_name(&self) -> &str {
50        "bootstrap.application.ApplicationBootstrapConfig"
51    }
52
53    fn config_schema_json(&self) -> String {
54        let api = ApplicationBootstrapSchemas::openapi();
55        serde_json::to_string(
56            &api.components
57                .as_ref()
58                .expect("OpenAPI components missing")
59                .schemas,
60        )
61        .expect("Failed to serialize config schema")
62    }
63
64    async fn create_bootstrap_provider(
65        &self,
66        _config_json: &serde_json::Value,
67        _source_config_json: &serde_json::Value,
68    ) -> anyhow::Result<Box<dyn BootstrapProvider>> {
69        Ok(Box::new(ApplicationBootstrapProvider::new()))
70    }
71}