Skip to content

Commit

Permalink
feat: add support for hetnzer cloud s3 storage (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
the-technat authored Oct 14, 2024
1 parent c24eddd commit 77a8c20
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ Currently the below providers are supported, but it could be used with other pro
- Cloudflare
- Vultr
- CleverCloud
- Hetzner Cloud

## Inputs

### `provider`

**Not Required** The s3 provider to use. Defaults to Linode. AWS, Linode, DigitalOcean, Scaleway, Cloudflare, Vultr, CleverCloud are supported.
**Not Required** The s3 provider to use. Defaults to Linode. AWS, Linode, DigitalOcean, Scaleway, Cloudflare, Vultr, CleverCloud, Hetzner Cloud are supported.

### `secret_key`

Expand Down
16 changes: 12 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24922,15 +24922,15 @@ exports["default"] = _default;
const defaults = __nccwpck_require__(724)

const providers = {
aws: ({ region = 'US', access_key = '', secret_key = ''}) => ({
aws: ({ region = 'US', access_key = '', secret_key = '' }) => ({
bucket_location: region,
host_base: 's3.amazonaws.com',
host_bucket: '%(bucket)s.s3.amazonaws.com',
website_endpoint: 'http://%(bucket)s.s3-website-%(location)s.amazonaws.com/',
access_key,
secret_key,
}),
digitalocean: ({ region = 'nyc3', access_key = '', secret_key = ''}) => ({
digitalocean: ({ region = 'nyc3', access_key = '', secret_key = '' }) => ({
bucket_location: region,
host_base: `${region}.digitaloceanspaces.com`,
host_bucket: `%(bucket)s.${region}.digitaloceanspaces.com`,
Expand All @@ -24954,15 +24954,15 @@ const providers = {
access_key,
secret_key,
}),
cloudflare: ({ account_id = '', region='auto', access_key = '', secret_key = '' }) => ({
cloudflare: ({ account_id = '', region = 'auto', access_key = '', secret_key = '' }) => ({
bucket_location: region,
host_base: `${account_id}.r2.cloudflarestorage.com`,
host_bucket: '',
website_endpoint: '',
access_key,
secret_key,
}),
vultr: ({ region = 'ewr1', access_key = '', secret_key = ''}) => ({
vultr: ({ region = 'ewr1', access_key = '', secret_key = '' }) => ({
bucket_location: region,
host_base: `${region}.vultrobjects.com`,
host_bucket: `%(bucket)s.${region}.vultrobjects.com`,
Expand All @@ -24978,6 +24978,14 @@ const providers = {
access_key,
secret_key,
}),
hcloud: ({ region = 'fsn1', access_key = '', secret_key = '' }) => ({
bucket_location: region,
host_base: `fsn1.your-objectstorage.com`,
host_bucket: `%(bucket)s.fsn1.your-objectstorage.com`,
website_endpoint: '',
access_key,
secret_key,
})
}

const makeConf = (provider) => {
Expand Down
16 changes: 12 additions & 4 deletions src/providers.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const defaults = require('./defaults.json')

const providers = {
aws: ({ region = 'US', access_key = '', secret_key = ''}) => ({
aws: ({ region = 'US', access_key = '', secret_key = '' }) => ({
bucket_location: region,
host_base: 's3.amazonaws.com',
host_bucket: '%(bucket)s.s3.amazonaws.com',
website_endpoint: 'http://%(bucket)s.s3-website-%(location)s.amazonaws.com/',
access_key,
secret_key,
}),
digitalocean: ({ region = 'nyc3', access_key = '', secret_key = ''}) => ({
digitalocean: ({ region = 'nyc3', access_key = '', secret_key = '' }) => ({
bucket_location: region,
host_base: `${region}.digitaloceanspaces.com`,
host_bucket: `%(bucket)s.${region}.digitaloceanspaces.com`,
Expand All @@ -33,15 +33,15 @@ const providers = {
access_key,
secret_key,
}),
cloudflare: ({ account_id = '', region='auto', access_key = '', secret_key = '' }) => ({
cloudflare: ({ account_id = '', region = 'auto', access_key = '', secret_key = '' }) => ({
bucket_location: region,
host_base: `${account_id}.r2.cloudflarestorage.com`,
host_bucket: '',
website_endpoint: '',
access_key,
secret_key,
}),
vultr: ({ region = 'ewr1', access_key = '', secret_key = ''}) => ({
vultr: ({ region = 'ewr1', access_key = '', secret_key = '' }) => ({
bucket_location: region,
host_base: `${region}.vultrobjects.com`,
host_bucket: `%(bucket)s.${region}.vultrobjects.com`,
Expand All @@ -57,6 +57,14 @@ const providers = {
access_key,
secret_key,
}),
hcloud: ({ region = 'fsn1', access_key = '', secret_key = '' }) => ({
bucket_location: region,
host_base: `fsn1.your-objectstorage.com`,
host_bucket: `%(bucket)s.fsn1.your-objectstorage.com`,
website_endpoint: '',
access_key,
secret_key,
})
}

const makeConf = (provider) => {
Expand Down
10 changes: 10 additions & 0 deletions src/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ const clevercloudConf = makeConf(providers.clevercloud({
for (const line of clevercloudConf) {
clevercloudWriter.write(line + '\r\n')
}

const hcloudWriter = createWriteStream('assets/test-results/hcloud')
const hcloudConf = makeConf(providers.hcloud({
access_key: 'top-secret',
secret_key: 'more secret'
}))

for (const line of hcloudConf) {
hcloudWriter.write(line + '\r\n')
}

0 comments on commit 77a8c20

Please sign in to comment.