@@ -5,7 +5,7 @@ use crate::args::OutputFormat;
55use crate :: util:: { EXIT_DSC_ERROR , EXIT_INVALID_ARGS , EXIT_JSON_ERROR , add_type_name_to_json, write_output} ;
66use dsc_lib:: configure:: config_doc:: { Configuration , ExecutionKind } ;
77use dsc_lib:: configure:: add_resource_export_results_to_configuration;
8- use dsc_lib:: dscresources:: invoke_result:: { GetResult , ResourceGetResponse } ;
8+ use dsc_lib:: dscresources:: { resource_manifest :: Kind , invoke_result:: { GetResult , ResourceGetResponse } } ;
99use dsc_lib:: dscerror:: DscError ;
1010use tracing:: { error, debug} ;
1111
@@ -22,6 +22,11 @@ pub fn get(dsc: &DscManager, resource_type: &str, mut input: String, format: &Op
2222 } ;
2323
2424 debug ! ( "resource.type_name - {} implemented_as - {:?}" , resource. type_name, resource. implemented_as) ;
25+ if resource. kind == Kind :: Adapter {
26+ error ! ( "Can not perform this operation on the adapter {} itself" , resource. type_name) ;
27+ exit ( EXIT_DSC_ERROR ) ;
28+ }
29+
2530 if let Some ( requires) = & resource. require_adapter {
2631 input = add_type_name_to_json ( input, resource. type_name . clone ( ) ) ;
2732 if let Some ( pr) = get_resource ( dsc, requires) {
@@ -59,6 +64,11 @@ pub fn get_all(dsc: &DscManager, resource_type: &str, format: &Option<OutputForm
5964 } ;
6065
6166 debug ! ( "resource.type_name - {} implemented_as - {:?}" , resource. type_name, resource. implemented_as) ;
67+ if resource. kind == Kind :: Adapter {
68+ error ! ( "Can not perform this operation on the adapter {} itself" , resource. type_name) ;
69+ exit ( EXIT_DSC_ERROR ) ;
70+ }
71+
6272 if let Some ( requires) = & resource. require_adapter {
6373 input = add_type_name_to_json ( input, resource. type_name . clone ( ) ) ;
6474 if let Some ( pr) = get_resource ( dsc, requires) {
@@ -106,6 +116,10 @@ pub fn set(dsc: &DscManager, resource_type: &str, mut input: String, format: &Op
106116 } ;
107117
108118 debug ! ( "resource.type_name - {} implemented_as - {:?}" , resource. type_name, resource. implemented_as) ;
119+ if resource. kind == Kind :: Adapter {
120+ error ! ( "Can not perform this operation on the adapter {} itself" , resource. type_name) ;
121+ exit ( EXIT_DSC_ERROR ) ;
122+ }
109123
110124 if let Some ( requires) = & resource. require_adapter {
111125 input = add_type_name_to_json ( input, resource. type_name . clone ( ) ) ;
@@ -148,6 +162,10 @@ pub fn test(dsc: &DscManager, resource_type: &str, mut input: String, format: &O
148162 } ;
149163
150164 debug ! ( "resource.type_name - {} implemented_as - {:?}" , resource. type_name, resource. implemented_as) ;
165+ if resource. kind == Kind :: Adapter {
166+ error ! ( "Can not perform this operation on the adapter {} itself" , resource. type_name) ;
167+ exit ( EXIT_DSC_ERROR ) ;
168+ }
151169
152170 if let Some ( requires) = & resource. require_adapter {
153171 input = add_type_name_to_json ( input, resource. type_name . clone ( ) ) ;
@@ -185,6 +203,10 @@ pub fn delete(dsc: &DscManager, resource_type: &str, mut input: String) {
185203 } ;
186204
187205 debug ! ( "resource.type_name - {} implemented_as - {:?}" , resource. type_name, resource. implemented_as) ;
206+ if resource. kind == Kind :: Adapter {
207+ error ! ( "Can not perform this operation on the adapter {} itself" , resource. type_name) ;
208+ exit ( EXIT_DSC_ERROR ) ;
209+ }
188210
189211 if let Some ( requires) = & resource. require_adapter {
190212 input = add_type_name_to_json ( input, resource. type_name . clone ( ) ) ;
@@ -210,6 +232,11 @@ pub fn schema(dsc: &DscManager, resource_type: &str, format: &Option<OutputForma
210232 error ! ( "{}" , DscError :: ResourceNotFound ( resource_type. to_string( ) ) . to_string( ) ) ;
211233 return
212234 } ;
235+ if resource. kind == Kind :: Adapter {
236+ error ! ( "Can not perform this operation on the adapter {} itself" , resource. type_name) ;
237+ exit ( EXIT_DSC_ERROR ) ;
238+ }
239+
213240 match resource. schema ( ) {
214241 Ok ( json) => {
215242 // verify is json
@@ -236,6 +263,11 @@ pub fn export(dsc: &mut DscManager, resource_type: &str, format: &Option<OutputF
236263 return
237264 } ;
238265
266+ if dsc_resource. kind == Kind :: Adapter {
267+ error ! ( "Can not perform this operation on the adapter {} itself" , dsc_resource. type_name) ;
268+ exit ( EXIT_DSC_ERROR ) ;
269+ }
270+
239271 let mut adapter_resource: Option < & DscResource > = None ;
240272 if let Some ( requires) = & dsc_resource. require_adapter {
241273 input = add_type_name_to_json ( input, dsc_resource. type_name . clone ( ) ) ;
0 commit comments