-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1010 from wss-git/wss/fix-customContainer-codeuri
Wss/fix custom container codeuri
- Loading branch information
Showing
12 changed files
with
81 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const _ = require('lodash'); | ||
const { execSync } = require('child_process'); | ||
|
||
async function getpushRegistry(image, pushRegistry, region, configImage) { | ||
const imageArr = image.split('/'); | ||
if (pushRegistry === 'acr-internet') { | ||
imageArr[0] = `registry.${region}.aliyuncs.com`; | ||
image = imageArr.join('/'); | ||
} else if (pushRegistry === 'acr-vpc') { | ||
imageArr[0] = `registry-vpc.${region}.aliyuncs.com`; | ||
image = imageArr.join('/'); | ||
} else if (pushRegistry) { | ||
imageArr[0] = pushRegistry; | ||
image = imageArr.join('/'); | ||
} | ||
console.log(`docker tag ${configImage} ${image}`); | ||
execSync(`docker tag ${configImage} ${image}`, { | ||
stdio: 'inherit' | ||
}); | ||
console.log(`docker push ${image}`); | ||
execSync(`docker push ${image}`, { | ||
stdio: 'inherit' | ||
}); | ||
} | ||
|
||
async function getFunctionImage({ tpl, pushRegistry, region }) { | ||
for (const k of _.keys(tpl)) { | ||
const v = tpl[k]; | ||
if (_.isObject(v)) { | ||
if (v.Type === 'Aliyun::Serverless::Function') { | ||
const { CustomContainerConfig = {} } = v.Properties || {}; | ||
let image = CustomContainerConfig.Image; | ||
if (image) { | ||
await getpushRegistry(image, pushRegistry, region, CustomContainerConfig.Image); | ||
} | ||
} else { | ||
await getFunctionImage({ tpl: v, pushRegistry, region }); | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = { | ||
getFunctionImage, getpushRegistry | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters