@@ -58,7 +58,28 @@ export async function exportKubeConfig(): Promise<void> {
5858 process . env . KUBECONFIG = kubeconfigPath ;
5959}
6060
61+ async function tryDescribingResourceToFile ( kind : string , name : string , namespace : string ) : Promise < void > {
62+ return kubectl . describeKubernetesResource ( kind , name , namespace )
63+ . then ( ( description ) => {
64+ const fileName = `${ kind } -${ name } -${ namespace } ` ;
65+ const filePath = process . env . CI
66+ // The directory is generated by CircleCI config (see .circleci/config.yml).
67+ ? `/tmp/logs/test/integration/openshift4/${ fileName } `
68+ : `${ tmpdir ( ) } /${ fileName } ` ;
69+ writeFileSync ( filePath , description ) ;
70+ console . log ( `Description for ${ kind } ${ name } is stored in ${ filePath } ` ) ;
71+ } )
72+ . catch ( ( ) => console . log ( `Could not describe ${ kind } ${ name } in namespace ${ namespace } ` ) ) ;
73+ }
74+
6175export async function clean ( ) : Promise < void > {
76+ await Promise . all ( [
77+ tryDescribingResourceToFile ( 'deployment' , 'snyk-operator' , 'snyk-monitor' ) ,
78+ tryDescribingResourceToFile ( 'deployment' , 'snyk-monitor' , 'snyk-monitor' ) ,
79+ tryDescribingResourceToFile ( 'operatorsource' , 'snyk-operator' , 'openshift-marketplace' ) ,
80+ tryDescribingResourceToFile ( 'subscription' , 'snyk-operator' , 'snyk-monitor' ) ,
81+ ] ) ;
82+
6283 // Kubernetes will be stuck trying to delete these resources if we don't clear the finalizers.
6384 await Promise . all ( [
6485 kubectl . patchResourceFinalizers ( 'customresourcedefinition' , 'snykmonitors.charts.helm.k8s.io' , 'snyk-monitor' ) . catch ( ( ) => undefined ) ,
0 commit comments