Skip to content

Commit

Permalink
more fake branches for uploaded files
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbo committed Dec 22, 2023
1 parent 1ec8b92 commit f6b442c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
4 changes: 1 addition & 3 deletions api/services/S3Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class S3Client {
results.push(...page[property]);
}
}

return results;
}

Expand Down Expand Up @@ -99,9 +100,6 @@ class S3Client {
// Concatenate S3 pages until there are enough for OUR page size
// eslint-disable-next-line no-restricted-syntax
for await (const page of paginator) {
if (!page.Contents) {
break;
}
objects.push(...page.Contents);
if (objects.length >= totalMaxObjects) {
break;
Expand Down
3 changes: 1 addition & 2 deletions api/utils/cfAuthClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class CloudFoundryAuthClient {
response_type: 'token',
}).toString(),
})
.then(response => response.data.access_token)
.catch(err => console.error(err));
.then(response => response.data.access_token);
}

tokenExpired() {
Expand Down
25 changes: 22 additions & 3 deletions scripts/localstack-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { Op } = require('sequelize');

const {
Build,
BuildLog,
BuildTask,
Site,
} = require('../api/models');
Expand All @@ -21,6 +20,16 @@ const s3 = new S3Client({
},
});

const fakeIndex = `<html>
<head>
<title>site</title>
</head>
<body>
Website
</body>
</html>
`;

const cmd = new CreateBucketCommand({ Bucket: config.s3BuildLogs.bucket });
s3.send(cmd);

Expand All @@ -29,14 +38,24 @@ Site.findAll()
sites.forEach(async (site) => {
const siteCmd = new CreateBucketCommand({ Bucket: site.awsBucketName });
await s3.send(siteCmd);
const folders = ['preview', 'site', 'demo']
const folders = ['site', 'demo'];
folders.forEach((folder) => {
const folderCmd = new PutObjectCommand({
Body: fakeIndex,
Bucket: site.awsBucketName,
Key: `${folder}/${site.owner}/${site.repository}`,
Key: `${folder}/${site.owner}/${site.repository}/index.html`,
});
s3.send(folderCmd);
});
const fakePreviews = ['branch1', 'branch2', 'branch3'];
fakePreviews.forEach((branch) => {
const previewCmd = new PutObjectCommand({
Body: fakeIndex,
Bucket: site.awsBucketName,
Key: `preview/${site.owner}/${site.repository}/${branch}/index.html`,
});
s3.send(previewCmd);
});
});
})
.catch(err => console.error(err));
Expand Down

0 comments on commit f6b442c

Please sign in to comment.