Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always create a backupS3Config and use it #2914

Merged
merged 1 commit into from
Nov 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions node-packages/commons/src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ export const createRemoveTask = async function(removeData: any) {
}

// creates the restore job configuration for use in the misc task
const restoreConfig = (name, backupId, safeProjectName, baasBucketName, backupS3Config, restoreS3Config) => {
const restoreConfig = (name, backupId, backupS3Config, restoreS3Config) => {
let config = {
apiVersion: 'backup.appuio.ch/v1alpha1',
kind: 'Restore',
Expand All @@ -806,9 +806,7 @@ const restoreConfig = (name, backupId, safeProjectName, baasBucketName, backupS3
s3: restoreS3Config ? restoreS3Config : {},
},
backend: {
s3: backupS3Config ? backupS3Config : {
bucket: baasBucketName ? baasBucketName : `baas-${safeProjectName}`
},
s3: backupS3Config,
repoPasswordSecretRef: {
key: 'repo-pw',
name: 'baas-repo-pw'
Expand Down Expand Up @@ -955,6 +953,10 @@ export const createMiscTask = async function(taskData: any) {
key: "secret-key"
}
}
} else {
backupS3Config = {
bucket: baasBucketName ? baasBucketName : `baas-${makeSafe(taskData.data.project.name)}`
}
}

// Handle custom restore configurations
Expand Down Expand Up @@ -1000,7 +1002,7 @@ export const createMiscTask = async function(taskData: any) {
}

// generate the restore CRD
const restoreConf = restoreConfig(restoreName, taskData.data.backup.backupId, makeSafe(taskData.data.project.name), baasBucketName, backupS3Config, restoreS3Config)
const restoreConf = restoreConfig(restoreName, taskData.data.backup.backupId, backupS3Config, restoreS3Config)
//logger.info(restoreConf)
// base64 encode it
const restoreBytes = new Buffer(JSON.stringify(restoreConf).replace(/\\n/g, "\n")).toString('base64')
Expand Down