Skip to content

Commit

Permalink
extent s3 options
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaffen committed Jul 11, 2023
1 parent 0572cc2 commit d98e9e8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,22 @@ Server Side storage
The will automatically populate the drop-down list of available reports, if they can be read from `reportlist.json`.
This file contains a record of the json files in `data`.
Assuming you have
```

```text
data/
file1.json
file2.json
```

the `reportlist.json` should have the format

```json
{
"First Report": "file1",
"Second Report": "file2"
}
```

The python script `generate_reportlist.py` will autopopulate it with all `data/*.json` using the filename also as key.

With the docker image, you can put everything in `/data`:
Expand All @@ -61,7 +65,6 @@ $ docker run -ti \
ghcr.io/voxpupuli/puppet-catalog-diff-viewer
```


S3 storage
----------

Expand All @@ -71,6 +74,11 @@ The viewer can automatically retrieve catalogs from an S3 bucket. In order to us
var s3_bucketName = 'your-bucket-name';
var s3_access_key = 'your-access-key';
var s3_secret_key = 'your-secret-key';

// if you selfhost a s3 engine or use a path within it:
var s3_host = 'your.endpoint.example.com';
var s3_bucketPathPrefix = '/yur/prefix';
var s3_ForcePathStyle = true;
```

With the docker image, you can use:
Expand Down Expand Up @@ -130,5 +138,3 @@ Make sure the access key belongs to a user that can perform actions `s3:GetObjec
]
}
```


11 changes: 7 additions & 4 deletions catalog_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,11 +964,14 @@ function refreshStats(type, data) {
function listS3Reports() {
AWS.config.update({accessKeyId: s3_access_key, secretAccessKey: s3_secret_key});
var s3Bucket = new AWS.S3({
params: {
Bucket: s3_bucketName
}
params: {
Bucket: s3_bucketName,
endpoint: s3_host, // Set the S3 host, when self hosting
s3ForcePathStyle: s3_ForcePathStyle, // Enable path-style URLs, necessary when using custom S3 host
}
});
s3Bucket.listObjects(function(err, data) {
// Add prefix to listObjects, if undefined, it is ignored
s3Bucket.listObjects({Prefix: s3_bucketPathPrefix}, function(err, data) {
if (err) {
console.log(err);
} else {
Expand Down
3 changes: 3 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ if test -n "$S3_BUCKET" ; then
var s3_bucketName = '${S3_BUCKET}';
var s3_access_key = '${S3_ACCESS_KEY}';
var s3_secret_key = '${S3_SECRET_KEY}';
var s3_host = '${S3_HOST}'; // S3 host, when self hosting s3
var s3_bucketPathPrefix = '${S3_BUCKET_PATH_PREFIX}'; // S3 bucket path prefix
var s3_ForcePathStyle = ${S3_FORCE_PATH_STYLE}; // true or false
EOF
fi

Expand Down

0 comments on commit d98e9e8

Please sign in to comment.