Skip to content

Commit db60887

Browse files
committed
fix: suppress label warning flag
Signed-off-by: Ganzidaeyong <[email protected]>
1 parent 35de1fa commit db60887

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/oci_cli/cli_root.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -559,21 +559,24 @@ def cli_auto_prompt_env():
559559

560560

561561
def check_key_for_security(auth, config_file, profile):
562-
563562
# put a condition to check this only for api based authentication
564563
if auth is None or auth == 'api_key':
565564
key_file = get_key_file(config_file, profile)
566565
if cli_constants.OCI_CLI_KEY_FILE_ENV_VAR in os.environ:
567566
key_file = os.environ[cli_constants.OCI_CLI_KEY_FILE_ENV_VAR]
568-
if os.getenv('SUPPRESS_LABEL_WARNING') is None:
569-
if key_file and not validate_label_private_key(key_file):
570-
private_label_message = (
571-
f"To increase security of your API key located at {key_file}, "
572-
"append an extra line with 'OCI_API_KEY' at the end. For more information, "
573-
"refer to https://docs.oracle.com/iaas/Content/API/Concepts/apisigningkey.htm"
574-
". To supress the warning, set the env variable SUPPRESS_LABEL_WARNING=True"
575-
)
576-
click.echo(click.style(f"Warning: {private_label_message}", fg='yellow'), err=True)
567+
568+
suppress_warning = os.getenv('SUPPRESS_LABEL_WARNING')
569+
if suppress_warning == 'True':
570+
return
571+
572+
if key_file and not validate_label_private_key(key_file):
573+
private_label_message = (
574+
f"To increase security of your API key located at {key_file}, "
575+
"append an extra line with 'OCI_API_KEY' at the end. For more information, "
576+
"refer to https://docs.oracle.com/iaas/Content/API/Concepts/apisigningkey.htm"
577+
". To suppress the warning, set the env variable SUPPRESS_LABEL_WARNING=True"
578+
)
579+
click.echo(click.style(f"Warning: {private_label_message}", fg='yellow'), err=True)
577580

578581

579582
def validate_label_private_key(file_path):

0 commit comments

Comments
 (0)