Skip to content

Commit

Permalink
Merge pull request #88 from atlanhq/fix-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
louisnow authored Sep 24, 2024
2 parents 206106f + 6efadce commit 38c6361
Show file tree
Hide file tree
Showing 3 changed files with 497 additions and 91 deletions.
26 changes: 21 additions & 5 deletions lib/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ class S3 {
}

initialize() {
return this.getS3ConfigFromArgo(this.configMapName, this.argoNamespace).then(({ bucket, region }) => {
this.client = new S3Client({ region: region });
this.bucketName = bucket;
this.s3KeyPrefix = `argo-artifacts/argopm/${this.package.name}/latest/static`;
});
return this.getS3ConfigFromArgo(this.configMapName, this.argoNamespace)
.then(({ bucket, region }) => {
this.client = new S3Client({ region: region });
this.bucketName = bucket;
this.s3KeyPrefix = `argo-artifacts/argopm/${this.package.name}/latest/static`;
})
.catch((err) => {
console.error("Erorr while initializing client");
console.error(err);
this.client = null;
this.bucketName = null;
this.s3KeyPrefix = null;
});
}

/**
Expand Down Expand Up @@ -62,6 +70,10 @@ class S3 {
* @param {String} path Absolute path of file
*/
uploadFile(path) {
if (this.client === null) {
console.log("Skipping upload file due to missing client");
return Promise.resolve();
}
const fileContent = fs.readFileSync(path, {
encoding: "utf-8",
flag: "r",
Expand Down Expand Up @@ -92,6 +104,10 @@ class S3 {
* @param {String} dirPath Absolute path of the directory
*/
uploadStaticFiles(dirPath) {
if (this.client === null) {
console.log("Skipping upload file due to missing client");
return Promise.resolve();
}
return walk(`${dirPath}/static`)
.then((dirs) => {
dirs = dirs.filter((dir) => !dir.endsWith(".md"));
Expand Down
Loading

0 comments on commit 38c6361

Please sign in to comment.