feat: add optional Provider attribute to S3 Destinations

This commit is contained in:
chuyun
2024-11-27 02:14:45 +08:00
parent fabe946526
commit 0477329db7
11 changed files with 4224 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ export const destinations = pgTable("destination", {
.primaryKey()
.$defaultFn(() => nanoid()),
name: text("name").notNull(),
provider: text("provider"),
accessKey: text("accessKey").notNull(),
secretAccessKey: text("secretAccessKey").notNull(),
bucket: text("bucket").notNull(),
@@ -37,6 +38,7 @@ export const destinationsRelations = relations(
const createSchema = createInsertSchema(destinations, {
destinationId: z.string(),
name: z.string().min(1),
provider: z.string(),
accessKey: z.string(),
bucket: z.string(),
endpoint: z.string(),
@@ -47,6 +49,7 @@ const createSchema = createInsertSchema(destinations, {
export const apiCreateDestination = createSchema
.pick({
name: true,
provider: true,
accessKey: true,
bucket: true,
region: true,

View File

@@ -28,9 +28,9 @@ export const removeScheduleBackup = (backupId: string) => {
};
export const getS3Credentials = (destination: Destination) => {
const { accessKey, secretAccessKey, bucket, region, endpoint } = destination;
const { accessKey, secretAccessKey, bucket, region, endpoint, provider } =
destination;
const rcloneFlags = [
// `--s3-provider=Cloudflare`,
`--s3-access-key-id=${accessKey}`,
`--s3-secret-access-key=${secretAccessKey}`,
`--s3-region=${region}`,
@@ -39,5 +39,9 @@ export const getS3Credentials = (destination: Destination) => {
"--s3-force-path-style",
];
if (provider) {
rcloneFlags.unshift(`--s3-provider=${provider}`);
}
return rcloneFlags;
};