Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate AWS script to axios #12833

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions scripts/aws/update-data
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const PARTITIONS = ['aws', 'aws-us-gov', 'aws-cn', 'aws-iso', 'aws-iso-b'];
const ENDPOINTS_URL = 'https://raw.githubusercontent.com/boto/botocore/develop/botocore/data/endpoints.json';
const JS_FILE = path.resolve(DIR, 'shell/assets/data/aws-regions.json');

const request = require('request');
const axios = require('axios');

function readExisting() {
const data = fs.readFileSync(JS_FILE).toString();
Expand Down Expand Up @@ -103,21 +103,15 @@ function checkService(endpoints, svc) {
return changes;
}

request(ENDPOINTS_URL, function (error, res, body) {
if (error) {
console.error('Could not fetch endpoints data');

process.exit(1);
}

if (res.statusCode !== 200) {
console.error(`Could not fetch endpoints data - status ${ res.statusCode } ${ res.statusMessage }`);
axios.get(ENDPOINTS_URL).then((res) => {
if (res.status !== 200 || !res.data) {
console.error(`Could not fetch endpoints data - status ${ res.status } ${ res.statusMessage }`);

process.exit(2);
}

try {
const endpoints = JSON.parse(body);
const endpoints = res.data;

checkService(endpoints, 'ec2');
} catch (e) {
Expand All @@ -126,4 +120,9 @@ request(ENDPOINTS_URL, function (error, res, body) {

process.exit(3);
}
});

}).catch((e) => {
console.error('Could not fetch endpoints data');

process.exit(1);
});
1 change: 1 addition & 0 deletions shell/assets/data/aws-regions.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ca-central-1",
"ca-west-1",
"cn-north-1",
Expand Down
Loading