Skip to content

Commit db3edba

Browse files
committed
Fix bugs
1 parent bd8e1c4 commit db3edba

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

dscbicep/src/main.rs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ impl BicepExtension for BicepExtensionService {
4646
resource: Some(proto::Resource {
4747
r#type: resource_type,
4848
api_version: version,
49-
identifiers: String::new(),
49+
identifiers: properties,
5050
properties: serde_json::to_string(&r).unwrap(),
5151
status: None,
5252
}),
5353
error_data: None,
5454
},
55-
Err(e) => return Err(Status::internal(format!("DSC set operation failed: {e}")))
55+
Err(e) => return Err(Status::internal(format!("DSC set operation failed: {e}"))),
5656
};
5757

5858
Ok(Response::new(result))
@@ -79,13 +79,17 @@ impl BicepExtension for BicepExtensionService {
7979
resource: Some(proto::Resource {
8080
r#type: resource_type,
8181
api_version: version,
82-
identifiers: String::new(),
82+
identifiers: properties,
8383
properties: serde_json::to_string(&r).unwrap(),
8484
status: None,
8585
}),
8686
error_data: None,
8787
},
88-
Err(e) => return Err(Status::internal(format!("DSC whatif operation failed: {e}")))
88+
Err(e) => {
89+
return Err(Status::internal(format!(
90+
"DSC whatif operation failed: {e}"
91+
)))
92+
}
8993
};
9094

9195
Ok(Response::new(result))
@@ -113,13 +117,13 @@ impl BicepExtension for BicepExtensionService {
113117
resource: Some(proto::Resource {
114118
r#type: resource_type,
115119
api_version: version,
116-
identifiers: String::new(),
120+
identifiers: identifiers,
117121
properties: serde_json::to_string(&r).unwrap(),
118122
status: None,
119123
}),
120124
error_data: None,
121125
},
122-
Err(e) => return Err(Status::internal(format!("DSC get operation failed: {e}")))
126+
Err(e) => return Err(Status::internal(format!("DSC get operation failed: {e}"))),
123127
};
124128

125129
Ok(Response::new(result))
@@ -152,13 +156,17 @@ impl BicepExtension for BicepExtensionService {
152156
resource: Some(proto::Resource {
153157
r#type: resource_type,
154158
api_version: version,
155-
identifiers: String::new(),
159+
identifiers: identifiers,
156160
properties: serde_json::to_string(&r).unwrap(),
157161
status: None,
158162
}),
159163
error_data: None,
160164
},
161-
Err(e) => return Err(Status::internal(format!("DSC delete operation failed: {e}")))
165+
Err(e) => {
166+
return Err(Status::internal(format!(
167+
"DSC delete operation failed: {e}"
168+
)))
169+
}
162170
};
163171

164172
Ok(Response::new(result))
@@ -209,10 +217,6 @@ async fn run_server(
209217
http: Option<String>,
210218
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
211219
let service = BicepExtensionService;
212-
let reflection_service = tonic_reflection::server::Builder::configure()
213-
.register_encoded_file_descriptor_set(proto::FILE_DESCRIPTOR_SET)
214-
.build_v1()
215-
.unwrap();
216220

217221
#[cfg(unix)]
218222
if let Some(socket_path) = socket {
@@ -228,7 +232,7 @@ async fn run_server(
228232
let uds_stream = UnixListenerStream::new(uds);
229233

230234
Server::builder()
231-
.add_service(reflection_service)
235+
// .add_service(reflection_service)
232236
.add_service(BicepExtensionServer::new(service))
233237
.serve_with_incoming(uds_stream)
234238
.await?;
@@ -249,6 +253,11 @@ async fn run_server(
249253
let addr = http.unwrap_or_else(|| "[::1]:50051".to_string()).parse()?;
250254
tracing::info!("Starting Bicep gRPC server on HTTP: {addr}");
251255

256+
let reflection_service = tonic_reflection::server::Builder::configure()
257+
.register_encoded_file_descriptor_set(proto::FILE_DESCRIPTOR_SET)
258+
.build_v1()
259+
.unwrap();
260+
252261
Server::builder()
253262
.add_service(reflection_service)
254263
.add_service(BicepExtensionServer::new(service))
@@ -280,7 +289,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
280289

281290
let args = Args::parse();
282291

283-
if args.wait_for_debugger || env::var_os("DSC_GRPC_DEBUG").is_some() {
292+
if args.wait_for_debugger
293+
|| env::var_os("DSC_GRPC_DEBUG").is_some_and(|v| v.eq_ignore_ascii_case("true"))
294+
{
284295
tracing::warn!(
285296
"Press any key to continue after attaching to PID: {}",
286297
process::id()

0 commit comments

Comments
 (0)