@@ -5,7 +5,7 @@ use crate::args::OutputFormat;
5
5
use crate :: util:: { EXIT_DSC_ERROR , EXIT_INVALID_ARGS , EXIT_JSON_ERROR , add_type_name_to_json, write_output} ;
6
6
use dsc_lib:: configure:: config_doc:: { Configuration , ExecutionKind } ;
7
7
use 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 } } ;
9
9
use dsc_lib:: dscerror:: DscError ;
10
10
use tracing:: { error, debug} ;
11
11
@@ -22,6 +22,11 @@ pub fn get(dsc: &DscManager, resource_type: &str, mut input: String, format: &Op
22
22
} ;
23
23
24
24
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
+
25
30
if let Some ( requires) = & resource. require_adapter {
26
31
input = add_type_name_to_json ( input, resource. type_name . clone ( ) ) ;
27
32
if let Some ( pr) = get_resource ( dsc, requires) {
@@ -59,6 +64,11 @@ pub fn get_all(dsc: &DscManager, resource_type: &str, format: &Option<OutputForm
59
64
} ;
60
65
61
66
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
+
62
72
if let Some ( requires) = & resource. require_adapter {
63
73
input = add_type_name_to_json ( input, resource. type_name . clone ( ) ) ;
64
74
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
106
116
} ;
107
117
108
118
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
+ }
109
123
110
124
if let Some ( requires) = & resource. require_adapter {
111
125
input = add_type_name_to_json ( input, resource. type_name . clone ( ) ) ;
@@ -143,6 +157,10 @@ pub fn test(dsc: &DscManager, resource_type: &str, mut input: String, format: &O
143
157
} ;
144
158
145
159
debug ! ( "resource.type_name - {} implemented_as - {:?}" , resource. type_name, resource. implemented_as) ;
160
+ if resource. kind == Kind :: Adapter {
161
+ error ! ( "Can not perform this operation on the adapter {} itself" , resource. type_name) ;
162
+ exit ( EXIT_DSC_ERROR ) ;
163
+ }
146
164
147
165
if let Some ( requires) = & resource. require_adapter {
148
166
input = add_type_name_to_json ( input, resource. type_name . clone ( ) ) ;
@@ -180,6 +198,10 @@ pub fn delete(dsc: &DscManager, resource_type: &str, mut input: String) {
180
198
} ;
181
199
182
200
debug ! ( "resource.type_name - {} implemented_as - {:?}" , resource. type_name, resource. implemented_as) ;
201
+ if resource. kind == Kind :: Adapter {
202
+ error ! ( "Can not perform this operation on the adapter {} itself" , resource. type_name) ;
203
+ exit ( EXIT_DSC_ERROR ) ;
204
+ }
183
205
184
206
if let Some ( requires) = & resource. require_adapter {
185
207
input = add_type_name_to_json ( input, resource. type_name . clone ( ) ) ;
@@ -205,6 +227,11 @@ pub fn schema(dsc: &DscManager, resource_type: &str, format: &Option<OutputForma
205
227
error ! ( "{}" , DscError :: ResourceNotFound ( resource_type. to_string( ) ) . to_string( ) ) ;
206
228
return
207
229
} ;
230
+ if resource. kind == Kind :: Adapter {
231
+ error ! ( "Can not perform this operation on the adapter {} itself" , resource. type_name) ;
232
+ exit ( EXIT_DSC_ERROR ) ;
233
+ }
234
+
208
235
match resource. schema ( ) {
209
236
Ok ( json) => {
210
237
// verify is json
@@ -231,6 +258,11 @@ pub fn export(dsc: &mut DscManager, resource_type: &str, format: &Option<OutputF
231
258
return
232
259
} ;
233
260
261
+ if dsc_resource. kind == Kind :: Adapter {
262
+ error ! ( "Can not perform this operation on the adapter {} itself" , dsc_resource. type_name) ;
263
+ exit ( EXIT_DSC_ERROR ) ;
264
+ }
265
+
234
266
let mut adapter_resource: Option < & DscResource > = None ;
235
267
if let Some ( requires) = & dsc_resource. require_adapter {
236
268
input = add_type_name_to_json ( input, dsc_resource. type_name . clone ( ) ) ;
0 commit comments