Skip to content

Commit

Permalink
fix pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
ricsam committed Dec 12, 2024
1 parent 33ae5ef commit a6d3365
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
16 changes: 16 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended", ":disableDependencyDashboard"],
"automerge": true,
"rangeStrategy": "replace",
"major": {
"automerge": false
},
"packageRules": [
{
"matchDepTypes": ["devDependencies"],
"automerge": true,
"rangeStrategy": "pin"
}
]
}
15 changes: 10 additions & 5 deletions src/backends/s3/create-s3-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { S3Client, type S3ClientConfig } from "@aws-sdk/client-s3";
import { parseS3Uri } from "./parse-s3-uri";
import { S3Client, type S3ClientConfig } from '@aws-sdk/client-s3';
import { parseS3Uri } from './parse-s3-uri';

export function createS3Client(uri: string): S3Client {
const parsed = parseS3Uri(uri);
Expand All @@ -13,8 +13,10 @@ export function createS3Client(uri: string): S3Client {
}

// Credentials precedence: URI > Environment Variables
const accessKeyId = parsed.credentials?.accessKeyId ?? process.env.AWS_ACCESS_KEY_ID;
const secretAccessKey = parsed.credentials?.secretAccessKey ?? process.env.AWS_SECRET_ACCESS_KEY;
const accessKeyId =
parsed.credentials?.accessKeyId ?? process.env.AWS_ACCESS_KEY_ID;
const secretAccessKey =
parsed.credentials?.secretAccessKey ?? process.env.AWS_SECRET_ACCESS_KEY;

if (accessKeyId && secretAccessKey) {
config.credentials = {
Expand All @@ -23,7 +25,10 @@ export function createS3Client(uri: string): S3Client {
};
}

config.endpoint = parsed.endpoint;
config.endpoint =
parsed.endpoint ??
process.env.AWS_ENDPOINT_URL_S3 ??
process.env.AWS_ENDPOINT_URL;

return new S3Client(config);
}
11 changes: 4 additions & 7 deletions src/backends/s3/parse-s3-uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ export function parseS3Uri(uri: string): ParsedS3Uri {
const [baseUri, queryString] = uri.split('?');

// Parse query params if present
const endpoint =
queryString
?.split('&')
.map((param) => param.split('='))
.find(([key]) => key === 'endpoint')?.[1] ??
process.env.AWS_ENDPOINT_URL_S3 ??
process.env.AWS_ENDPOINT_URL;
const endpoint = queryString
?.split('&')
.map((param) => param.split('='))
.find(([key]) => key === 'endpoint')?.[1];

if (!baseUri.startsWith('s3://')) {
throw new Error('Invalid S3 URI format');
Expand Down

0 comments on commit a6d3365

Please sign in to comment.