-
Notifications
You must be signed in to change notification settings - Fork 86
bucket notifications - facilitate notif conf to override connection #8932
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,13 +10,38 @@ const notif_util = require('../../../util/notifications_util'); | |
async function put_bucket_notification(req) { | ||
|
||
let topic_configuration = req.body.NotificationConfiguration?.TopicConfiguration; | ||
const default_connection = req.object_sdk.requesting_account.default_connection; | ||
|
||
//adapt to db shcema | ||
if (topic_configuration) { | ||
for (const conf of topic_configuration) { | ||
conf.id = conf.Id; | ||
conf.event = conf.Event; | ||
conf.topic = conf.Topic; | ||
//handle Kafka's topic synax, if present | ||
if (conf.Topic && conf.Topic.length > 0 && conf.Topic[0].startsWith('kafka:::topic/')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldn't it be also good to have a validation on the cli level. that you wouldn't be able to configure default_connection of this format? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, if it doesn't have a "special" syntax, its fine |
||
//kafka_topic_parts is, by index: | ||
//kafka_topic_parts[0] = 'kafka:::topic' | ||
alphaprinz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//kafka_topic_parts[1] = connection, optional | ||
//kafka_topic_parts[2] = Kafka topic, mandatory | ||
const kafka_topic_parts = conf.Topic[0].split('/'); | ||
if (kafka_topic_parts.length !== 3) { | ||
throw new S3Error({ | ||
code: 'InvalidArgument', | ||
message: "kafka:::topic is invalid. Must be of syntax: kafka:::topic:/connection/topic", | ||
http_code: 400, | ||
detail: conf.Topic[0] | ||
}); | ||
} | ||
//connection is optionally kafka_topic_parts[1], default to account's default_connection | ||
let connection = default_connection; | ||
if (typeof kafka_topic_parts[1] === 'string' && kafka_topic_parts[1].length > 0) { | ||
connection = kafka_topic_parts[1]; | ||
} | ||
const topic = kafka_topic_parts[2]; | ||
//write the full Topic string with the connection | ||
conf.topic = ['kafka:::topic/' + connection + "/" + topic]; | ||
} | ||
delete conf.Id; | ||
delete conf.Event; | ||
delete conf.Topic; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,8 @@ const FROM_FILE = 'from_file'; | |
const ANONYMOUS = 'anonymous'; | ||
|
||
const VALID_OPTIONS_ACCOUNT = { | ||
'add': new Set(['name', 'uid', 'gid', 'supplemental_groups', 'new_buckets_path', 'user', 'access_key', 'secret_key', 'fs_backend', 'allow_bucket_creation', 'force_md5_etag', 'iam_operate_on_root_account', FROM_FILE, ...CLI_MUTUAL_OPTIONS]), | ||
'update': new Set(['name', 'uid', 'gid', 'supplemental_groups', 'new_buckets_path', 'user', 'access_key', 'secret_key', 'fs_backend', 'allow_bucket_creation', 'force_md5_etag', 'iam_operate_on_root_account', 'new_name', 'regenerate', ...CLI_MUTUAL_OPTIONS]), | ||
'add': new Set(['name', 'uid', 'gid', 'supplemental_groups', 'new_buckets_path', 'user', 'access_key', 'secret_key', 'fs_backend', 'allow_bucket_creation', 'force_md5_etag', 'iam_operate_on_root_account', 'default_connection', FROM_FILE, ...CLI_MUTUAL_OPTIONS]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this part of the account configuration. shouldn't it be per bucket? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently in Marc's project the user and connection creation would be done by one admin user (with manage_nsfs cli), while buckets and their notif conf would be done by other (not-admin) users (with s3 rest api). So the admin would be able to do a once-per-system users and connection creation (including user's default connection), and then the other users wouldn't need to know about connections at all. |
||
'update': new Set(['name', 'uid', 'gid', 'supplemental_groups', 'new_buckets_path', 'user', 'access_key', 'secret_key', 'fs_backend', 'allow_bucket_creation', 'force_md5_etag', 'iam_operate_on_root_account', 'new_name', 'regenerate', 'default_connection', ...CLI_MUTUAL_OPTIONS]), | ||
'delete': new Set(['name', ...CLI_MUTUAL_OPTIONS]), | ||
'list': new Set(['wide', 'show_secrets', 'gid', 'uid', 'user', 'name', 'access_key', ...CLI_MUTUAL_OPTIONS]), | ||
'status': new Set(['name', 'access_key', 'show_secrets', ...CLI_MUTUAL_OPTIONS]), | ||
|
@@ -142,6 +142,7 @@ const OPTION_TYPE = { | |
ips: 'string', | ||
force: 'boolean', | ||
anonymous: 'boolean', | ||
default_connection: 'string', | ||
// health options | ||
deployment_type: 'string', | ||
all_account_details: 'boolean', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,5 +101,8 @@ module.exports = { | |
} | ||
}] | ||
}, | ||
default_connection: { | ||
type: 'string' | ||
} | ||
} | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.