import * as util from "util" ; export interface K8sSecret { data : { token : string ; "ca.crt" : string ; } ; } param secret returns export function parseK8sSecret ( secret ) { if ( ! secret ) throw Error ( "K8s secret yaml is invalid" ) ; if ( ! secret . data ) throw k8sSecretMissingFieldError ( "data" ) ; if ( ! secret . data . token ) throw k8sSecretMissingFieldError ( "token" ) ; if ( ! secret . data [ "ca.crt" ] ) throw k8sSecretMissingFieldError ( "ca.crt" ) ; return secret as K8sSecret ; } const k8sSecretMissingFieldError = ( field ) : Error => Error ( util . format ( "K8s secret yaml does not contain %s field" , field ) ) ;