@@ -16,7 +16,7 @@ import { memoize } from "@wok/utils/memoize";
16
16
import { parseMultiDocumentsYaml , stringifyYamlRelaxed } from "./yaml_utils.ts" ;
17
17
import { gray } from "@std/fmt/colors" ;
18
18
import { toFileUrl } from "@std/path/to-file-url" ;
19
- import { Arr , createTypedParser , Obj , type ParseResult , Str , typedParse , type TypedSchema } from "../deps/schema.ts" ;
19
+ import { Arr , createValidator , Obj , Str , type TypedSchema , validate , type ValidationResult } from "../deps/schema.ts" ;
20
20
21
21
export interface ImportDef {
22
22
props : string [ ] ;
@@ -38,7 +38,7 @@ export function createTypeifyPatch(
38
38
export async function decryptAndValidateSecrets < T > (
39
39
schema : TypedSchema < T , unknown > ,
40
40
encryptedSecretsPath : string ,
41
- ) : Promise < ParseResult < T > > {
41
+ ) : Promise < ValidationResult < T > > {
42
42
const raw = await ( async ( ) => {
43
43
try {
44
44
return ( await captureExec ( {
@@ -54,7 +54,7 @@ export async function decryptAndValidateSecrets<T>(
54
54
55
55
const decrypted = parseYaml ( raw ) ;
56
56
57
- return typedParse ( schema , decrypted ) ;
57
+ return validate ( schema , decrypted ) ;
58
58
}
59
59
60
60
export function createK8sSecretsDecryptor < T > (
@@ -83,7 +83,7 @@ export function createK8sSecretsDecryptor<T>(
83
83
} ) ;
84
84
}
85
85
86
- const validateChartMeta = createTypedParser ( ChartMetadataSchema ) ;
86
+ const validateChartMeta = createValidator ( ChartMetadataSchema ) ;
87
87
88
88
export async function readChartMeta ( chartPath : string ) : Promise < ChartMetadata > {
89
89
const chartMetaPath = joinPath (
@@ -104,7 +104,7 @@ export async function readChartMeta(chartPath: string): Promise<ChartMetadata> {
104
104
return chartMetaResult . value ;
105
105
}
106
106
107
- const validateCrds = createTypedParser ( Arr ( K8sCrdSchema ) ) ;
107
+ const validateCrds = createValidator ( Arr ( K8sCrdSchema ) ) ;
108
108
109
109
export async function collectCrdFiles ( chartPath : string ) : Promise < string [ ] > {
110
110
const crdsPath = joinPath ( chartPath , "crds" ) ;
@@ -160,7 +160,7 @@ export async function readChartCrds(chartPath: string): Promise<K8sCrd[]> {
160
160
) ;
161
161
}
162
162
163
- const validateK8sResource = createTypedParser ( K8sResourceSchema ) ;
163
+ const validateK8sResource = createValidator ( K8sResourceSchema ) ;
164
164
165
165
const memoizedAllApiVersions = memoize ( async ( ) => {
166
166
const apiVersionsFromEnv = Deno . env . get ( "HELMET_KUBECTL_API_VERSIONS" ) ;
@@ -239,14 +239,14 @@ const memoizedKubeVersion = memoize(async () => {
239
239
const json = JSON . parse ( out ) ;
240
240
241
241
if ( useServerVersion ) {
242
- const validation = typedParse ( KubectlServerVersionCmdOutputSchema , json ) ;
242
+ const validation = validate ( KubectlServerVersionCmdOutputSchema , json ) ;
243
243
if ( ! validation . isSuccess ) {
244
244
throw new Error ( `Got invalid output for command: ${ cmd . join ( " " ) } ` ) ;
245
245
}
246
246
return validation . value . serverVersion . gitVersion ;
247
247
}
248
248
249
- const validation = typedParse ( KubectlClientVersionCmdOutputSchema , json ) ;
249
+ const validation = validate ( KubectlClientVersionCmdOutputSchema , json ) ;
250
250
if ( ! validation . isSuccess ) {
251
251
throw new Error ( `Got invalid output for command: ${ cmd . join ( " " ) } ` ) ;
252
252
}
@@ -335,7 +335,7 @@ ${JSON.stringify(docResult.errors, null, 2)}
335
335
return transformedDocs ;
336
336
}
337
337
338
- const validateK8sCrd = createTypedParser ( K8sCrdSchema ) ;
338
+ const validateK8sCrd = createValidator ( K8sCrdSchema ) ;
339
339
340
340
export const HelmLsResultSchema = Arr ( Obj ( {
341
341
name : Str ( ) ,
0 commit comments