MinIO support for Admin UI (#2248)
Add support for MinIO creation form and list
This commit is contained in:
1 parent
98c16ad422
commit
0870a8f623
26 files changed
+1332
-597
No files matched your search
@@ -73,6 +73,12 @@ export default class GeneratedStorageBucketModel extends BaseModel {
|
||||
})
|
||||
region;
|
||||
|
||||
@attr('string', {
|
||||
isNestedAttribute: true,
|
||||
description: 'The MinIO location server.',
|
||||
})
|
||||
endpoint_url;
|
||||
|
||||
//this field is not used in the UI, but this is kept here to replicate the API
|
||||
@attr('string', {
|
||||
readOnly: true,
|
||||
|
||||
@@ -9,8 +9,10 @@ export const TYPE_STORAGE_BUCKET_PLUGIN = 'plugin';
|
||||
export const TYPES_STORAGE_BUCKET = Object.freeze([TYPE_STORAGE_BUCKET_PLUGIN]);
|
||||
|
||||
export const TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3 = 'aws';
|
||||
export const TYPE_STORAGE_BUCKET_PLUGIN_MINIO = 'minio';
|
||||
export const TYPES_STORAGE_BUCKET_PLUGIN = Object.freeze([
|
||||
TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3,
|
||||
TYPE_STORAGE_BUCKET_PLUGIN_MINIO,
|
||||
]);
|
||||
|
||||
export const TYPE_CREDENTIAL_STATIC = 'static';
|
||||
@@ -75,6 +77,14 @@ export default class StorageBucketModel extends GeneratedStorageBucketModel {
|
||||
return this.compositeType === TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the storage bucket plugin type is MinIO
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isMinIO() {
|
||||
return this.compositeType === TYPE_STORAGE_BUCKET_PLUGIN_MINIO;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the storage bucket is a plugin return `plugin.name`,
|
||||
* otherwise return the storage bucket type.
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
*/
|
||||
|
||||
import ApplicationSerializer from './application';
|
||||
import { TYPE_CREDENTIAL_DYNAMIC } from '../models/storage-bucket';
|
||||
import {
|
||||
TYPE_CREDENTIAL_DYNAMIC,
|
||||
TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3,
|
||||
} from '../models/storage-bucket';
|
||||
|
||||
const fieldsByCredentialType = {
|
||||
static: [
|
||||
@@ -12,27 +15,55 @@ const fieldsByCredentialType = {
|
||||
'secret_access_key',
|
||||
'region',
|
||||
'disable_credential_rotation',
|
||||
'endpoint_url',
|
||||
],
|
||||
dynamic: [
|
||||
'role_arn',
|
||||
'role_external_id',
|
||||
'role_session_name',
|
||||
'role_tags',
|
||||
'disable_credential_rotation',
|
||||
'region',
|
||||
'disable_credential_rotation',
|
||||
'endpoint_url',
|
||||
],
|
||||
};
|
||||
export default class StorageBucketSerializer extends ApplicationSerializer {
|
||||
/**
|
||||
* Serializes storage-bucket. ATM just AWS needs specific serialization,
|
||||
* for the other plugin types use default.
|
||||
* @param {object} snapshot
|
||||
* @returns
|
||||
*/
|
||||
serialize(snapshot) {
|
||||
const serialized = super.serialize(...arguments);
|
||||
const { credentialType } = snapshot.record;
|
||||
const pluginType = snapshot.record.plugin?.name;
|
||||
const serialized = super.serialize(...arguments);
|
||||
|
||||
// Common for all pluginTypes
|
||||
if (!snapshot.record.isNew) {
|
||||
delete serialized.bucket_name;
|
||||
delete serialized.bucket_prefix;
|
||||
}
|
||||
|
||||
if (credentialType === TYPE_CREDENTIAL_DYNAMIC) {
|
||||
serialized.attributes.disable_credential_rotation = true;
|
||||
if (pluginType === TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3) {
|
||||
return this.serializeAws(serialized, credentialType);
|
||||
}
|
||||
|
||||
return serialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a storage bucket serialized object specific for aws
|
||||
* @param {object} serialized
|
||||
* @param {string} credentialType
|
||||
* @returns
|
||||
*/
|
||||
serializeAws(serialized, credentialType) {
|
||||
if (serialized.attributes) {
|
||||
if (credentialType === TYPE_CREDENTIAL_DYNAMIC) {
|
||||
serialized.attributes.disable_credential_rotation = true;
|
||||
}
|
||||
delete serialized.attributes.endpoint_url;
|
||||
}
|
||||
return serialized;
|
||||
}
|
||||
@@ -45,7 +76,7 @@ export default class StorageBucketSerializer extends ApplicationSerializer {
|
||||
if (options.isNestedAttribute && json.attributes) {
|
||||
// The key must be included in the fieldsByType list above
|
||||
if (!fieldsByCredentialType[credentialType].includes(key))
|
||||
//API requires these fields to be null
|
||||
// API requires these fields to be null
|
||||
json.attributes[key] = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user