Fixup gcs backup storage configuration
This commit is contained in:
@@ -121,16 +121,10 @@ async function onSubmit() {
|
||||
data.noHardlinks = !providerConfig.value.useHardlinks;
|
||||
data.preserveAttributes = true;
|
||||
} else if (data.provider === 'gcs') {
|
||||
// TODO we should probably allow to change the config without reuploading a new .json
|
||||
if (providerConfig.value.gcsKeyContentJson) return;
|
||||
|
||||
data.bucket = providerConfig.value.bucket;
|
||||
data.prefix = providerConfig.value.prefix;
|
||||
data.projectId = providerConfig.value.gcsKeyContentJson.project_id;
|
||||
data.credentials = {
|
||||
client_email: providerConfig.value.gcsKeyContentJson.client_email,
|
||||
private_key: providerConfig.value.gcsKeyContentJson.private_key
|
||||
};
|
||||
data.projectId = providerConfig.value.projectId;
|
||||
data.credentials = providerConfig.value.credentials;
|
||||
}
|
||||
|
||||
const limits = {
|
||||
|
||||
@@ -26,8 +26,6 @@ const storageProviders = STORAGE_PROVIDERS.concat([
|
||||
const blockDevices = ref([]);
|
||||
const disk = ref('');
|
||||
const gcsKeyFileName = ref('');
|
||||
const gcsProjectId = ref('');
|
||||
const gcsKeyContentJson = ref(null);
|
||||
const gcsFileParseError = ref('');
|
||||
const advancedVisible = ref(false);
|
||||
|
||||
@@ -47,15 +45,20 @@ function onGcsKeyChange(event) {
|
||||
if (!keyJson.client_email) throw new Error('client_email field missing in JSON key file');
|
||||
if (!keyJson.private_key) throw new Error('private_key field missing in JSON key file');
|
||||
|
||||
gcsProjectId.value = keyJson.project_id;
|
||||
gcsKeyContentJson.value = keyJson;
|
||||
providerConfig.value.projectId = keyJson.project_id;
|
||||
providerConfig.value.credentials = {
|
||||
client_email: keyJson.client_email,
|
||||
private_key: keyJson.private_key,
|
||||
};
|
||||
} catch (e) {
|
||||
if (e.name === 'SyntaxError') gcsFileParseError.value = 'Invalid JSON';
|
||||
else gcsFileParseError.value = e.message;
|
||||
|
||||
gcsKeyFileName.value = '';
|
||||
gcsProjectId.value = '';
|
||||
gcsKeyContentJson.value = null;
|
||||
providerConfig.value.projectId = '';
|
||||
providerConfig.value.credentials = {
|
||||
client_email: '',
|
||||
private_key: '',
|
||||
};
|
||||
}
|
||||
};
|
||||
fr.readAsText(event.target.files[0]);
|
||||
@@ -263,8 +266,8 @@ onMounted(async () => {
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup v-if="provider === 'gcs'">
|
||||
<input type="file" id="gcsKeyFileInput" style="display:none" @change="onGcsKeyChange"/>
|
||||
<label for="gcsKeyInput">{{ $t('backups.configureBackupStorage.gcsServiceKey') }}{{ providerConfig.gcsProjectId ? ` - project: ${providerConfig.gcsProjectId}` : '' }}</label>
|
||||
<input type="file" id="gcsKeyFileInput" style="display:none" accept="application/json, text/json" @change="onGcsKeyChange"/>
|
||||
<label for="gcsKeyInput">{{ $t('backups.configureBackupStorage.gcsServiceKey') }}{{ providerConfig.projectId ? ` - project: ${providerConfig.projectId}` : '' }}</label>
|
||||
<InputGroup>
|
||||
<TextInput readonly required style="flex-grow: 1" v-model="gcsKeyFileName" placeholder="Service Account Key" onclick="document.getElementById('gcsKeyFileInput').click();"/>
|
||||
<Button tool icon="fa fa-upload" onclick="document.getElementById('gcsKeyFileInput').click();"/>
|
||||
|
||||
Reference in New Issue
Block a user