public void appendImageStreamResource ( ImageName imageName , File target ) throws MojoExecutionException { String tag = StringUtils . isBlank ( imageName . getTag ( ) ) ? "latest" : imageName . getTag ( ) ; try { ImageStream is = new ImageStreamBuilder ( ) . withNewMetadata ( ) . withName ( imageName . getSimpleName ( ) ) . endMetadata ( ) . withNewSpec ( ) . addNewTag ( ) . withName ( tag ) . withNewFrom ( ) . withKind ( "ImageStreamImage" ) . endFrom ( ) . endTag ( ) . endSpec ( ) . build ( ) ; createOrUpdateImageStreamTag ( client , imageName , is ) ; appendImageStreamToFile ( is , target ) ; log . info ( "ImageStream %s written to %s" , imageName . getSimpleName ( ) , target ) ; } catch ( KubernetesClientException e ) { KubernetesResourceUtil . handleKubernetesClientException ( e , this . log ) ; } catch ( IOException e ) { throw new MojoExecutionException ( String . format ( "Cannot write ImageStream descriptor for %s to %s : %s" , imageName . getFullName ( ) , target . getAbsoluteFile ( ) , e . getMessage ( ) ) , e ) ; } }
Save the images stream to a file