@@ -26,7 +26,7 @@ namespace Microsoft.Azure.Commands.StorageSync.Evaluation.Cmdlets
26
26
using Models ;
27
27
28
28
[ Cmdlet ( "Invoke" , Azure . Commands . ResourceManager . Common . AzureRMConstants . AzureRMPrefix + "StorageSyncCompatibilityCheck" , DefaultParameterSetName = "PathBased" ) ]
29
- [ OutputType ( typeof ( PSValidationResult ) ) ]
29
+ [ OutputType ( typeof ( PSStorageSyncValidation ) ) ]
30
30
public class InvokeCompatibilityCheckCmdlet : Cmdlet , ICmdlet
31
31
{
32
32
#region Fields and Properties
@@ -94,9 +94,6 @@ private string UserName
94
94
[ Parameter ( ParameterSetName = "PathBased" ) ]
95
95
public SwitchParameter SkipNamespaceChecks { get ; set ; }
96
96
97
- [ Parameter ]
98
- public SwitchParameter Quiet { get ; set ; }
99
-
100
97
private bool CanRunNamespaceChecks => ! string . IsNullOrEmpty ( this . Path ) ;
101
98
private bool CanRunEstimation => this . CanRunNamespaceChecks ;
102
99
private bool CanRunSystemChecks => ! string . IsNullOrEmpty ( this . ComputerNameValue . Value ) ;
@@ -111,36 +108,17 @@ protected override void ProcessRecord()
111
108
Configuration configuration = new Configuration ( ) ;
112
109
113
110
// prepare namespace validations
114
- var namespaceValidations = new List < INamespaceValidation > ( )
115
- {
116
- new InvalidFilenameValidation ( configuration ) ,
117
- new FilenamesCharactersValidation ( configuration ) ,
118
- new MaximumFileSizeValidation ( configuration ) ,
119
- new MaximumPathLengthValidation ( configuration ) ,
120
- new MaximumFilenameLengthValidation ( configuration ) ,
121
- new MaximumTreeDepthValidation ( configuration ) ,
122
- new MaximumDatasetSizeValidation ( configuration ) ,
123
- } ;
111
+ IList < INamespaceValidation > namespaceValidations = ValidationsFactory . GetNamespaceValidations ( configuration ) ;
124
112
125
113
// prepare system validations
126
- var systemValidations = new List < ISystemValidation >
127
- {
128
- new OSVersionValidation ( configuration ) ,
129
- } ;
130
-
131
- if ( this . CanRunNamespaceChecks )
132
- {
133
- systemValidations . Add ( new FileSystemValidation ( configuration , this . Path ) ) ;
134
- }
135
-
136
- // construct validation descriptions
137
- List < IValidationDescription > validationDescriptions = new List < IValidationDescription > ( ) ;
138
- namespaceValidations . ForEach ( o => validationDescriptions . Add ( ( IValidationDescription ) o ) ) ;
139
- systemValidations . ForEach ( o => validationDescriptions . Add ( ( IValidationDescription ) o ) ) ;
114
+ IList < ISystemValidation > systemValidations = ValidationsFactory . GetSystemValidations ( configuration , this . Path ) ;
140
115
141
116
// output writers
142
- TextSummaryOutputWriter summaryWriter = new TextSummaryOutputWriter ( new AfsConsoleWriter ( ) , validationDescriptions ) ;
143
- PsObjectsOutputWriter psObjectsWriter = new PsObjectsOutputWriter ( this ) ;
117
+ var validationResultWriter = new PSValidationResultOutputWriter ( ) ;
118
+ var outputWriters = new List < IOutputWriter >
119
+ {
120
+ validationResultWriter
121
+ } ;
144
122
145
123
this . WriteVerbose ( $ "Path = { this . Path } ") ;
146
124
this . WriteVerbose ( $ "ComputerName = { this . ComputerName } ") ;
@@ -150,7 +128,6 @@ protected override void ProcessRecord()
150
128
this . WriteVerbose ( $ "CanRunEstimation = { this . CanRunEstimation } ") ;
151
129
this . WriteVerbose ( $ "SkipNamespaceChecks = { this . SkipNamespaceChecks } ") ;
152
130
this . WriteVerbose ( $ "SkipSystemChecks = { this . SkipSystemChecks } ") ;
153
- this . WriteVerbose ( $ "Quiet = { this . Quiet } ") ;
154
131
this . WriteVerbose ( $ "NumberOfSystemChecks = { systemValidations . Count } ") ;
155
132
this . WriteVerbose ( $ "NumberOfNamespaceChecks = { namespaceValidations . Count } ") ;
156
133
@@ -202,7 +179,7 @@ protected override void ProcessRecord()
202
179
203
180
progressReporter . AddSteps ( systemValidations . Count ) ;
204
181
Stopwatch stopwatch = Stopwatch . StartNew ( ) ;
205
- this . PerformSystemChecks ( systemValidations , progressReporter , this , summaryWriter , psObjectsWriter ) ;
182
+ this . PerformSystemChecks ( systemValidations , progressReporter , this , outputWriters ) ;
206
183
stopwatch . Stop ( ) ;
207
184
progressReporter . Complete ( ) ;
208
185
TimeSpan duration = stopwatch . Elapsed ;
@@ -223,7 +200,7 @@ protected override void ProcessRecord()
223
200
224
201
Stopwatch stopwatch = Stopwatch . StartNew ( ) ;
225
202
namespaceInfo = this . RunActionWithUncConnectionIfNeeded < INamespaceInfo > (
226
- ( ) => this . StorageEval ( namespaceValidations , progressReporter , this , summaryWriter , psObjectsWriter ) ) ;
203
+ ( ) => this . StorageEval ( namespaceValidations , progressReporter , this , outputWriters ) ) ;
227
204
stopwatch . Stop ( ) ;
228
205
progressReporter . Complete ( ) ;
229
206
@@ -237,19 +214,20 @@ protected override void ProcessRecord()
237
214
this . WriteVerbose ( "Skipping namespace checks." ) ;
238
215
}
239
216
240
- if ( ! this . Quiet . ToBool ( ) )
241
- {
242
- summaryWriter . WriteReport ( this . ComputerNameValue . Value , namespaceInfo ) ;
243
- }
244
- else
217
+ var validationModel = validationResultWriter . Validation ;
218
+ validationModel . ComputerName = this . ComputerNameValue . Value ;
219
+ if ( namespaceInfo != null )
245
220
{
246
- this . WriteVerbose ( "Skipping report." ) ;
221
+ validationModel . NamespacePath = namespaceInfo . Path ;
222
+ validationModel . NamespaceDirectoryCount = namespaceInfo . NumberOfDirectories ;
223
+ validationModel . NamespaceFileCount = namespaceInfo . NumberOfFiles ;
247
224
}
225
+ this . WriteObject ( validationModel ) ;
248
226
}
249
227
#endregion
250
228
251
229
#region Private methods
252
- private void PerformSystemChecks ( IList < ISystemValidation > validations , IProgressReporter progressReporter , ICmdlet cmdlet , TextSummaryOutputWriter summaryWriter , PsObjectsOutputWriter psObjectsWriter )
230
+ private void PerformSystemChecks ( IList < ISystemValidation > validations , IProgressReporter progressReporter , ICmdlet cmdlet , IList < IOutputWriter > outputWriters )
253
231
{
254
232
PowerShellCommandRunner commandRunner = null ;
255
233
@@ -266,12 +244,6 @@ private void PerformSystemChecks(IList<ISystemValidation> validations, IProgress
266
244
throw ;
267
245
}
268
246
269
- var outputWriters = new List < IOutputWriter >
270
- {
271
- summaryWriter ,
272
- psObjectsWriter
273
- } ;
274
-
275
247
SystemValidationsProcessor systemChecksProcessor = new SystemValidationsProcessor ( commandRunner , validations , outputWriters , progressReporter ) ;
276
248
277
249
systemChecksProcessor . Run ( ) ;
@@ -305,16 +277,10 @@ private T RunActionWithUncConnectionIfNeeded<T>(Func<T> action)
305
277
return result ;
306
278
}
307
279
308
- private INamespaceInfo StorageEval ( IList < INamespaceValidation > validations , IProgressReporter progressReporter , ICmdlet cmdlet , TextSummaryOutputWriter summaryWriter , PsObjectsOutputWriter psObjectsWriter )
280
+ private INamespaceInfo StorageEval ( IList < INamespaceValidation > validations , IProgressReporter progressReporter , ICmdlet cmdlet , IList < IOutputWriter > outputWriters )
309
281
{
310
282
IDirectoryInfo root = new AfsDirectoryInfo ( this . Path ) ;
311
283
312
- var outputWriters = new List < IOutputWriter >
313
- {
314
- psObjectsWriter ,
315
- summaryWriter
316
- } ;
317
-
318
284
NamespaceValidationsProcessor validationsProcessor = new NamespaceValidationsProcessor ( validations , outputWriters , progressReporter ) ;
319
285
320
286
List < INamespaceEnumeratorListener > namespaceEnumeratorListeners = new List < INamespaceEnumeratorListener >
0 commit comments