@@ -162,7 +162,7 @@ def config_already_warned(cls):
162
162
return False
163
163
164
164
@classmethod
165
- def load_config (cls , opts , path = None , profile = None ):
165
+ def load_config (cls , opts , path = None , profile = None , no_warn = False ):
166
166
"""Load a configuration file into an options object."""
167
167
if path and os .path .exists (path ):
168
168
if os .path .isdir (path ):
@@ -174,12 +174,14 @@ def load_config(cls, opts, path=None, profile=None):
174
174
values = config .get ("default" , {})
175
175
cls ._load_values_into_opts (opts , values )
176
176
177
+ warn = not no_warn and not cls .config_already_warned ()
178
+
177
179
if profile and profile != "default" :
178
180
try :
179
181
values = config ["profile:%s" % profile ]
180
182
cls ._load_values_into_opts (opts , values )
181
183
except KeyError :
182
- if not cls . config_already_warned () :
184
+ if warn :
183
185
click .secho (
184
186
f"Warning: profile { profile } not found in config files { cls .config_files } " ,
185
187
fg = "yellow" ,
@@ -188,7 +190,7 @@ def load_config(cls, opts, path=None, profile=None):
188
190
existing_config_paths = {
189
191
path : os .path .exists (path ) for path in cls .config_files
190
192
}
191
- if not any (existing_config_paths .values ()) and not cls . config_already_warned () :
193
+ if not any (existing_config_paths .values ()) and warn :
192
194
click .secho (
193
195
"Warning: No config files found in search paths. Tried the following:" ,
194
196
fg = "yellow" ,
@@ -246,7 +248,7 @@ class CredentialsReader(ConfigReader):
246
248
config_section_schemas = [CredentialsSchema .Default , CredentialsSchema .Profile ]
247
249
248
250
@classmethod
249
- def load_config (cls , opts , path = None , profile = None ):
251
+ def load_config (cls , opts , path = None , profile = None , no_warn = False ):
250
252
"""
251
253
Load a credentials configuration file into an options object.
252
254
We overload the load_config command in CredentialsReader as
@@ -269,6 +271,7 @@ def load_config(cls, opts, path=None, profile=None):
269
271
return values
270
272
271
273
274
+ # pylint: disable=too-many-public-methods
272
275
class Options :
273
276
"""Options object that holds config for the application."""
274
277
@@ -289,15 +292,15 @@ def get_creds_reader():
289
292
"""Get the credentials config reader class."""
290
293
return CredentialsReader
291
294
292
- def load_config_file (self , path , profile = None ):
295
+ def load_config_file (self , path , profile = None , no_warn = False ):
293
296
"""Load the standard config file."""
294
297
config_cls = self .get_config_reader ()
295
- return config_cls .load_config (self , path , profile = profile )
298
+ return config_cls .load_config (self , path , profile = profile , no_warn = no_warn )
296
299
297
- def load_creds_file (self , path , profile = None ):
300
+ def load_creds_file (self , path , profile = None , no_warn = False ):
298
301
"""Load the credentials config file."""
299
302
config_cls = self .get_creds_reader ()
300
- return config_cls .load_config (self , path , profile = profile )
303
+ return config_cls .load_config (self , path , profile = profile , no_warn = no_warn )
301
304
302
305
@property
303
306
def api_config (self ):
@@ -330,6 +333,16 @@ def api_host(self, value):
330
333
"""Set value for API host."""
331
334
self ._set_option ("api_host" , value )
332
335
336
+ @property
337
+ def no_warn (self ):
338
+ """Get value for API host."""
339
+ return self ._get_option ("no_warn" )
340
+
341
+ @no_warn .setter
342
+ def no_warn (self , value ):
343
+ """Set value for API host."""
344
+ self ._set_option ("no_warn" , value )
345
+
333
346
@property
334
347
def api_key (self ):
335
348
"""Get value for API key."""
0 commit comments