@@ -1152,6 +1152,47 @@ obj:
1152
1152
} )
1153
1153
. then ( done , done ) ;
1154
1154
} ) ;
1155
+
1156
+ it ( 'single custom kubernetes schema version should return validation errors' , async ( ) => {
1157
+ const customKubernetesSchemaVersion =
1158
+ 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.26.1-standalone-strict/all.json' ;
1159
+ yamlSettings . kubernetesSchemaUrls = [ customKubernetesSchemaVersion ] ;
1160
+ const settingsHandler = new SettingsHandler ( { } as Connection , languageService , yamlSettings , validationHandler , telemetry ) ;
1161
+ const initialSettings = languageSettingsSetup . withKubernetes ( true ) . languageSettings ;
1162
+ const kubernetesSettings = settingsHandler . configureSchemas (
1163
+ customKubernetesSchemaVersion ,
1164
+ [ '*k8s.yml' ] ,
1165
+ undefined ,
1166
+ initialSettings ,
1167
+ SchemaPriority . SchemaAssociation
1168
+ ) ;
1169
+ languageService . configure ( kubernetesSettings ) ;
1170
+ const content = `apiVersion: apps/v1\nkind: Deployment\nfoo: bar` ;
1171
+ const result = await parseSetup ( content , 'invalid-k8s.yml' ) ;
1172
+ expect ( result . length ) . to . eq ( 1 ) ;
1173
+ expect ( result [ 0 ] . message ) . to . eq ( 'Property foo is not allowed.' ) ;
1174
+ } ) ;
1175
+
1176
+ it ( 'single openshift schema version should return validation errors' , async ( ) => {
1177
+ const customOpenshiftSchemaVersion =
1178
+ 'https://raw.githubusercontent.com/tricktron/CRDs-catalog/f-openshift-v4.11/openshift.io/v4.11/all.json' ;
1179
+ yamlSettings . kubernetesSchemaUrls = [ customOpenshiftSchemaVersion ] ;
1180
+ const settingsHandler = new SettingsHandler ( { } as Connection , languageService , yamlSettings , validationHandler , telemetry ) ;
1181
+ const initialSettings = languageSettingsSetup . withKubernetes ( true ) . languageSettings ;
1182
+ const kubernetesSettings = settingsHandler . configureSchemas (
1183
+ customOpenshiftSchemaVersion ,
1184
+ [ '*oc.yml' ] ,
1185
+ undefined ,
1186
+ initialSettings ,
1187
+ SchemaPriority . SchemaAssociation
1188
+ ) ;
1189
+ languageService . configure ( kubernetesSettings ) ;
1190
+ const content = `apiVersion: route.openshift.io/v1\nkind: Route\nfoo: bar` ;
1191
+ const result = await parseSetup ( content , 'invalid-oc.yml' ) ;
1192
+ expect ( result . length ) . to . eq ( 2 ) ;
1193
+ expect ( result [ 0 ] . message ) . to . eq ( 'Missing property "spec".' ) ;
1194
+ expect ( result [ 1 ] . message ) . to . eq ( 'Property foo is not allowed.' ) ;
1195
+ } ) ;
1155
1196
} ) ;
1156
1197
1157
1198
// https://github.com/redhat-developer/yaml-language-server/issues/118
0 commit comments