diff --git a/providers/prometheus/src/config.rs b/providers/prometheus/src/config.rs index bba335c..56d1c9e 100644 --- a/providers/prometheus/src/config.rs +++ b/providers/prometheus/src/config.rs @@ -29,3 +29,18 @@ pub(crate) async fn query_config(_query: ConfigQuery, config: Config) -> Result< Yaml(response.data.yaml).to_blob() } + +pub fn create_code_cell(response: Blob) -> Result> { + let code_cell = Cell::Code( + CodeCell::builder() + .id("config".to_owned()) + .content(String::from_utf8(response.data.into()).map_err(|err| { + Error::Deserialization { + message: err.to_string(), + } + })?) + .syntax("yaml") + .build(), + ); + Ok(vec![code_cell]) +} diff --git a/providers/prometheus/src/lib.rs b/providers/prometheus/src/lib.rs index decfe23..42e91ff 100644 --- a/providers/prometheus/src/lib.rs +++ b/providers/prometheus/src/lib.rs @@ -50,11 +50,12 @@ pdk_query_types! { } #[pdk_export] -fn create_cells(query_type: String, _response: Blob) -> Result> { +fn create_cells(query_type: String, response: Blob) -> Result> { log(format!("Creating cells for query type: {query_type}")); match query_type.as_str() { TIMESERIES_QUERY_TYPE => create_graph_cell(), + YAML_MIME_TYPE => create_code_cell(response), _ => Err(Error::UnsupportedRequest), } }