Skip to content

Commit e681b34

Browse files
committed
chore(eng-7893): removing duplicate warnings
1 parent 66f84ae commit e681b34

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

cloudsmith_cli/cli/commands/repos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def print_repositories(opts, data, page_info=None, show_list_info=True):
6060
@decorators.common_cli_output_options
6161
@decorators.common_api_auth_options
6262
@decorators.initialise_api
63-
@decorators.verify_authenticated
6463
@click.pass_context
6564
def repositories(ctx, opts): # pylink: disable=unused-argument
6665
"""
@@ -76,6 +75,7 @@ def repositories(ctx, opts): # pylink: disable=unused-argument
7675
@decorators.common_cli_output_options
7776
@decorators.common_api_auth_options
7877
@decorators.initialise_api
78+
@decorators.verify_authenticated
7979
@click.argument(
8080
"owner_repo",
8181
metavar="OWNER/REPO",

cloudsmith_cli/cli/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,11 @@ def load_config(cls, opts, path=None, profile=None):
179179
values = config["profile:%s" % profile]
180180
cls._load_values_into_opts(opts, values)
181181
except KeyError:
182-
click.secho(
183-
f"Warning: profile {profile} not found in config files {cls.config_files}",
184-
fg="yellow",
185-
)
182+
if not cls.config_already_warned():
183+
click.secho(
184+
f"Warning: profile {profile} not found in config files {cls.config_files}",
185+
fg="yellow",
186+
)
186187

187188
existing_config_paths = {
188189
path: os.path.exists(path) for path in cls.config_files

cloudsmith_cli/cli/decorators.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,22 +315,35 @@ def call_print_rate_limit_info_with_opts(rate_info):
315315
def verify_authenticated(f):
316316
"""Verify that the user is authenticated and warn if not."""
317317

318+
@click.option(
319+
"--no-warn",
320+
default=False,
321+
is_flag=True,
322+
help="Don't warn on misconfiguration issues",
323+
)
318324
@click.pass_context
319325
@functools.wraps(f)
320326
def wrapper(ctx, *args, **kwargs):
321327
cloudsmith_host = kwargs["opts"].opts["api_config"].host
328+
print(kwargs["opts"].opts["api_config"].__dict__)
329+
no_warn = kwargs.pop("no_warn")
322330
is_auth, _, _, _ = get_user_brief()
323-
if not is_auth:
331+
if not is_auth and not no_warn:
324332
click.secho(
325333
"Warning: You are not authenticated with the API. "
326334
"Please verify your config files, API key and "
327335
"run `cloudsmith login` if necessary to authenticate.",
328336
fg="yellow",
329337
)
330338
click.secho(
331-
f"You're currently attemping to connect to Cloudsmith instance {cloudsmith_host}",
339+
f"You're currently attempting to connect to Cloudsmith instance {cloudsmith_host}",
332340
fg="yellow",
333341
)
342+
no_warn = True
343+
344+
opts = config.get_or_create_options(ctx)
345+
opts.no_warn = no_warn
346+
kwargs["opts"] = opts
334347
return ctx.invoke(f, *args, **kwargs)
335348

336349
return wrapper

0 commit comments

Comments
 (0)