Skip to content

Commit b2810b4

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

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/oci_cli/cli_root.py

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

560560

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

578582

579583
def validate_label_private_key(file_path):

0 commit comments

Comments
 (0)