@@ -7,6 +7,16 @@ import {spawnSync} from "child_process";
7
7
import { BaseService } from "./base-service.js" ;
8
8
import { ServiceResponse } from "../types/service.js" ;
9
9
import { SleekCommand } from "../sleek-command.js" ;
10
+ import { ValidateOptions } from "../types/validate.js" ;
11
+
12
+ export const SuccessResponse :ServiceResponse < string > = {
13
+ success : true ,
14
+ } ;
15
+
16
+ export const ValidationSkipped :ServiceResponse < string > = {
17
+ success : true ,
18
+ body :'validation skipped'
19
+ } ;
10
20
11
21
export default class ChartValidatorService extends BaseService {
12
22
// this will always be a local filepath
@@ -21,9 +31,9 @@ export default class ChartValidatorService extends BaseService {
21
31
22
32
}
23
33
24
- public async validate ( ) : Promise < ServiceResponse < any > > {
34
+ public async validate ( ops : ValidateOptions ) : Promise < ServiceResponse < any > > {
25
35
const capabilities = await this . findCapabilities ( ) ;
26
- const hooks = await this . findHooks ( ) ;
36
+ const hooks = ops . skipHooksValidation ? ValidationSkipped : await this . findHooks ( ) ;
27
37
const dependencies = await this . findDependencies ( ) ;
28
38
29
39
let response : ServiceResponse < string > = {
@@ -82,14 +92,10 @@ export default class ChartValidatorService extends BaseService {
82
92
encoding : "utf-8"
83
93
} ) ;
84
94
85
- let response : ServiceResponse < string > ;
86
-
87
95
if ( capabilities . stdout === "" ) {
88
- response = {
89
- success : true ,
90
- }
96
+ return SuccessResponse
91
97
} else {
92
- response = {
98
+ return {
93
99
success : false ,
94
100
body : "Unsupported system Capabilities are used in chart." ,
95
101
error : {
@@ -101,20 +107,16 @@ export default class ChartValidatorService extends BaseService {
101
107
}
102
108
}
103
109
}
104
-
105
- return response ;
106
110
}
107
111
108
112
private async findHooks ( ) : Promise < ServiceResponse < string > > {
109
113
const hooks = spawnSync ( 'grep' , [ '-Rile' , '".Hooks"' , this . toValidate ] , { shell : true , encoding : "utf-8" } ) ;
110
114
111
115
let response : ServiceResponse < string > ;
112
116
if ( hooks . stdout === "" ) {
113
- response = {
114
- success : true ,
115
- }
117
+ return SuccessResponse
116
118
} else {
117
- response = {
119
+ return {
118
120
success : false ,
119
121
body : "Unsupported system Hooks are used in chart." ,
120
122
error : {
@@ -126,8 +128,6 @@ export default class ChartValidatorService extends BaseService {
126
128
}
127
129
}
128
130
}
129
-
130
- return response ;
131
131
}
132
132
133
133
private async findDependencies ( ) : Promise < ServiceResponse < string > > {
@@ -150,11 +150,9 @@ export default class ChartValidatorService extends BaseService {
150
150
const allDepsFiles = dependencies . every ( dep => dep . includes ( 'file://' ) ) ;
151
151
152
152
if ( allDepsFiles ) {
153
- response = {
154
- success : true ,
155
- }
153
+ return SuccessResponse
156
154
} else {
157
- response = {
155
+ return {
158
156
success : false ,
159
157
body : "Not all dependencies reside in the main chart." ,
160
158
error : {
@@ -166,7 +164,5 @@ export default class ChartValidatorService extends BaseService {
166
164
}
167
165
}
168
166
}
169
-
170
- return response ;
171
167
}
172
168
}
0 commit comments