Skip to content

Commit 45d571b

Browse files
committed
NC | Small fixes
Signed-off-by: Romy <35330373+romayalon@users.noreply.github.com>
1 parent 25bbf89 commit 45d571b

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/manage_nsfs/manage_nsfs_constants.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ const VALID_OPTIONS_ACCOUNT = {
5151
};
5252

5353
const VALID_OPTIONS_ANONYMOUS_ACCOUNT = {
54-
'add': new Set(['uid', 'gid', 'user', 'anonymous', CONFIG_ROOT_FLAG]),
55-
'update': new Set(['uid', 'gid', 'user', 'anonymous', CONFIG_ROOT_FLAG]),
56-
'delete': new Set(['anonymous', CONFIG_ROOT_FLAG]),
57-
'status': new Set(['anonymous', CONFIG_ROOT_FLAG]),
54+
'add': new Set(['uid', 'gid', 'user', 'anonymous', ...CLI_MUTUAL_OPTIONS]),
55+
'update': new Set(['uid', 'gid', 'user', 'anonymous', ...CLI_MUTUAL_OPTIONS]),
56+
'delete': new Set(['anonymous', ...CLI_MUTUAL_OPTIONS]),
57+
'status': new Set(['anonymous', ...CLI_MUTUAL_OPTIONS]),
5858
};
5959

6060
const VALID_OPTIONS_BUCKET = {

src/manage_nsfs/manage_nsfs_validations.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ async function check_new_name_exists(type, config_fs, action, data) {
335335
async function check_new_access_key_exists(config_fs, action, data) {
336336
const new_access_key = action === ACTIONS.ADD ? data.access_keys?.[0]?.access_key : data.new_access_key;
337337
if (action === ACTIONS.UPDATE && !is_access_key_update(data)) return;
338+
if (!new_access_key) return; // for anonymous account and users without access keys
338339
const exists = await config_fs.is_account_exists_by_access_key(new_access_key);
339340
if (exists) throw_cli_error(ManageCLIError.AccountAccessKeyAlreadyExists, new_access_key, { account: new_access_key });
340341
}
@@ -457,11 +458,12 @@ async function validate_account_args(config_fs, data, action, is_flag_iam_operat
457458
if (!exists) {
458459
throw_cli_error(ManageCLIError.InvalidAccountNewBucketsPath, data.nsfs_account_config.new_buckets_path);
459460
}
460-
if (config.NC_DISABLE_ACCESS_CHECK) return;
461-
const account_fs_context = await native_fs_utils.get_fs_context(data.nsfs_account_config, data.fs_backend);
462-
const accessible = await native_fs_utils.is_dir_rw_accessible(account_fs_context, data.nsfs_account_config.new_buckets_path);
463-
if (!accessible) {
464-
throw_cli_error(ManageCLIError.InaccessibleAccountNewBucketsPath, data.nsfs_account_config.new_buckets_path);
461+
if (!config.NC_DISABLE_ACCESS_CHECK) {
462+
const account_fs_context = await native_fs_utils.get_fs_context(data.nsfs_account_config, data.fs_backend);
463+
const accessible = await native_fs_utils.is_dir_rw_accessible(account_fs_context, data.nsfs_account_config.new_buckets_path);
464+
if (!accessible) {
465+
throw_cli_error(ManageCLIError.InaccessibleAccountNewBucketsPath, data.nsfs_account_config.new_buckets_path);
466+
}
465467
}
466468
if (action === ACTIONS.UPDATE && is_flag_iam_operate_on_root_account_update_action) {
467469
await validate_root_accounts_manager_update(config_fs, data);

0 commit comments

Comments
 (0)