-
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 #1038 from wss-git/wss/add-policy-to-user
feat(deploy/ros-codeuri): deploy support ros codeyuri
- Loading branch information
Showing
7 changed files
with
135 additions
and
59 deletions.
There are no files selected for viewing
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,55 @@ | ||
const { getProfile } = require('./profile'); | ||
const { getOssClient } = require('./client'); | ||
const { promptForConfirmContinue, promptForInputContinue } = require('./init/prompt'); | ||
const { yellow } = require('colors'); | ||
|
||
const _ = require('lodash'); | ||
|
||
|
||
async function bucketExist(ossClient, bucketName) { | ||
let bucketExist = false; | ||
|
||
try { | ||
await ossClient.getBucketLocation(bucketName); | ||
bucketExist = true; | ||
} catch (ex) { | ||
|
||
if (!ex.code || !_.includes(['AccessDenied', 'NoSuchBucket'], ex.code)) { | ||
throw ex; | ||
} | ||
} | ||
return bucketExist; | ||
} | ||
|
||
|
||
async function generateOssBucket(bucketName) { | ||
const ossClient = await getOssClient(); | ||
|
||
if (await bucketExist(ossClient, bucketName)) { | ||
console.log(yellow(`using oss-bucket: ${bucketName}`)); | ||
return bucketName; | ||
} | ||
|
||
console.log(yellow(`using oss-bucket: ${bucketName}`)); | ||
|
||
if (process.stdin.isTTY && !await promptForConfirmContinue('Auto generate OSS bucket for you?')) { | ||
bucketName = (await promptForInputContinue('Input OSS bucket name:')).input; | ||
} | ||
|
||
await ossClient.putBucket(bucketName); | ||
|
||
return bucketName; | ||
} | ||
|
||
async function processOSSBucket(bucket) { | ||
if (!bucket) { | ||
const profile = await getProfile(); | ||
const defalutBucket = `fun-gen-${profile.defaultRegion}-${profile.accountId}`; | ||
return await generateOssBucket(defalutBucket); | ||
} | ||
return await generateOssBucket(bucket); | ||
} | ||
|
||
module.exports = { | ||
processOSSBucket | ||
}; |
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