@@ -10,7 +10,7 @@ const debug = require('debug')('fun:deploy');
1010const definition = require ( '../definition' ) ;
1111const date = require ( 'date-and-time' ) ;
1212
13- const { execSync } = require ( 'child_process ' ) ;
13+ const { getFunctionImage } = require ( '../package/pushImage ' ) ;
1414const { deployByRos } = require ( './deploy-support-ros' ) ;
1515const { importService } = require ( '../import/service' ) ;
1616const { getProfile, mark } = require ( '../profile' ) ;
@@ -939,44 +939,6 @@ async function deployByApi(baseDir, tpl, tplPath, context) {
939939 }
940940}
941941
942- async function getpushRegistry ( image , pushRegistry , region , configImage ) {
943- const imageArr = image . split ( '/' ) ;
944- if ( pushRegistry === 'acr-internet' ) {
945- imageArr [ 0 ] = `registry.${ region } .aliyuncs.com` ;
946- image = imageArr . join ( '/' ) ;
947- } else if ( pushRegistry === 'acr-vpc' ) {
948- imageArr [ 0 ] = `registry-vpc.${ region } .aliyuncs.com` ;
949- image = imageArr . join ( '/' ) ;
950- } else if ( pushRegistry ) {
951- imageArr [ 0 ] = pushRegistry ;
952- image = imageArr . join ( '/' ) ;
953- }
954- console . log ( `docker tag ${ configImage } ${ image } ` ) ;
955- execSync ( `docker tag ${ configImage } ${ image } ` , {
956- stdio : 'inherit'
957- } ) ;
958- console . log ( `docker push ${ image } ` ) ;
959- execSync ( `docker push ${ image } ` , {
960- stdio : 'inherit'
961- } ) ;
962- }
963-
964- async function getFunctionImage ( { tpl, pushRegistry, region } ) {
965- for ( const k of _ . keys ( tpl ) ) {
966- const v = tpl [ k ] ;
967- if ( _ . isObject ( v ) ) {
968- if ( v . Type === 'Aliyun::Serverless::Function' ) {
969- const { CustomContainerConfig = { } } = v . Properties || { } ;
970- let image = CustomContainerConfig . Image ;
971- if ( image ) {
972- await getpushRegistry ( image , pushRegistry , region , CustomContainerConfig . Image ) ;
973- }
974- } else {
975- await getFunctionImage ( { tpl : v , pushRegistry, region } ) ;
976- }
977- }
978- }
979- }
980942
981943async function deploy ( tplPath , context ) {
982944 if ( ! context . useRos ) {
@@ -990,7 +952,7 @@ async function deploy(tplPath, context) {
990952 const profile = await getProfile ( ) ;
991953
992954 if ( context . pushRegistry ) {
993- getFunctionImage ( { tpl, region : profile . defaultRegion , pushRegistry : context . pushRegistry } ) ;
955+ await getFunctionImage ( { tpl, region : profile . defaultRegion , pushRegistry : context . pushRegistry } ) ;
994956 }
995957
996958 console . log ( `using region: ${ profile . defaultRegion } ` ) ;
0 commit comments