-
Notifications
You must be signed in to change notification settings - Fork 695
Add argument --iam-token-file in ydb-dstool #20303
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
base: main
Are you sure you want to change the base?
Conversation
⚪ Test history | Ya make output | Test bloat
🟢 |
🟢 |
⚪ Test history | Ya make output | Test bloat
🟢 |
81c853c
to
680decc
Compare
⚪ Test history | Ya make output | Test bloat
🟢 |
⚪ Test history | Ya make output | Test bloat
🟢 |
⚪ Test history | Ya make output | Test bloat
🟢 |
⚪ Test history | Ya make output | Test bloat
🟢 |
⚪ Test history | Ya make output | Test bloat
🟢 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for an --iam-token-file
CLI argument in ydb-dstool
, automatically handling “Bearer” prefixing and fallback to IAM environment variables or default files.
- Extend
parse_token
to acceptiam_token_file
, handleIAM_TOKEN
env var, and default IAM token path. - Introduce helper methods
read_token_from_file
,read_token_file
, andparse_token_value
. - Update
add_host_access_options
to use a mutually exclusive group for--token-file
and--iam-token-file
.
Comments suppressed due to low confidence (2)
ydb/apps/dstool/lib/common.py:234
- New IAM token handling logic should be covered by unit tests to verify behavior for
--iam-token-file
,IAM_TOKEN
env var, and default file fallbacks.
self.parse_token(args.token_file, args.iam_token_file)
ydb/apps/dstool/lib/common.py:195
- The helper
read_token_from_file_and_close
is not defined, leading to a NameError. Consider using a context manager (e.g.,with open(...) as f:
) combined withread_token_from_file
, or implement the missing function.
return self.read_token_from_file_and_close(open(token_file_path, 'r'), default_token_type)
return default_token_type, None | ||
try: | ||
return self.read_token_from_file_and_close(open(token_file_path, 'r'), default_token_type) | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid a bare except Exception:
which can mask unrelated errors; catch specific file I/O exceptions like FileNotFoundError
or OSError
instead.
except Exception: | |
except (FileNotFoundError, OSError): |
Copilot uses AI. Check for mistakes.
Changelog entry
Add --iam-token-file argument to ydb-dstool
Changelog category
Description for reviewers
For IAM token need to add "Bearer " in begining of the token if use --token-file.
Added new argument --iam-token-file which will do it insead of user