cob icon indicating copy to clipboard operation
cob copied to clipboard

This plugin is literally unconfigurable

Open syskill opened this issue 3 years ago • 0 comments

Due to the use of this anti-pattern:

metadata_server = "http://169.254.169.254"

...

def get_iam_role(url=metadata_server, version="latest",
                 params="meta-data/iam/security-credentials/"):

...

        global timeout, retries, metadata_server
        timeout = self.conduit.confInt('aws', 'timeout', default=timeout)
        retries = self.conduit.confInt('aws', 'retries', default=retries)
        metadata_server = self.conduit.confString('aws',
                                                  'metadata_server',
                                                  default=metadata_server)

...

        iam_role = get_iam_role()

Python binds the default argument values when the function is defined, and so the later override has no effect, as you can see below:

Python 2.7.18 (default, Jun 10 2021, 00:11:02)
[GCC 7.3.1 20180712 (Red Hat 7.3.1-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> globalvar = 'Hello'
>>> def foo(a=globalvar):
...     print a
...
>>> globalvar = 'Goodbye'
>>> foo()
Hello

Consequently the metadata_server, retries, and timeout settings in the config file are not used, if different from the default values.

syskill avatar Jan 20 '22 01:01 syskill