protected void addFrom ( BuildImageConfiguration . Builder builder ) { String fromMode = getConfigWithFallback ( Config . fromMode , "fabric8.generator.fromMode" , getFromModeDefault ( context . getRuntimeMode ( ) ) ) ; String from = getConfigWithFallback ( Config . from , "fabric8.generator.from" , null ) ; if ( "docker" . equalsIgnoreCase ( fromMode ) ) { String fromImage = from ; if ( fromImage == null ) { fromImage = fromSelector != null ? fromSelector . getFrom ( ) : null ; } builder . from ( fromImage ) ; log . info ( "Using Docker image %s as base / builder" , fromImage ) ; } else if ( "istag" . equalsIgnoreCase ( fromMode ) ) { Map < String , String > fromExt = new HashMap <> ( ) ; if ( from != null ) { ImageName iName = new ImageName ( from ) ; // user/project is considered to be the namespace String tag = iName . getTag ( ) ; if ( StringUtils . isBlank ( tag ) ) { tag = "latest" ; } fromExt . put ( OpenShiftBuildStrategy . SourceStrategy . name . key ( ) , iName . getSimpleName ( ) + ":" + tag ) ; if ( iName . getUser ( ) != null ) { fromExt . put ( OpenShiftBuildStrategy . SourceStrategy . namespace . key ( ) , iName . getUser ( ) ) ; } fromExt . put ( OpenShiftBuildStrategy . SourceStrategy . kind . key ( ) , "ImageStreamTag" ) ; } else { fromExt = fromSelector != null ? fromSelector . getImageStreamTagFromExt ( ) : null ; } if ( fromExt != null ) { String namespace = fromExt . get ( OpenShiftBuildStrategy . SourceStrategy . namespace . key ( ) ) ; if ( namespace != null ) { log . info ( "Using ImageStreamTag '%s' from namespace '%s' as builder image" , fromExt . get ( OpenShiftBuildStrategy . SourceStrategy . name . key ( ) ) , namespace ) ; } else { log . info ( "Using ImageStreamTag '%s' as builder image" , fromExt . get ( OpenShiftBuildStrategy . SourceStrategy . name . key ( ) ) ) ; } builder . fromExt ( fromExt ) ; } } else { throw new IllegalArgumentException ( String . format ( "Invalid 'fromMode' in generator configuration for '%s'" , getName ( ) ) ) ; } }
Add the base image either from configuration or from a given selector